function printUpperTriangular(matrix : any) {
const rows = matrix.length;
const cols = matrix[0].length;
for (let i = 0; i < rows; i++) {
let s = "";
for (let j = 0; j < cols; j++) {
if (i > j) {
s += "0" + " "
}
else {
s += matrix[i][j] + " ";
}
}
console.log(s);
}
}
const matrix = [ [4, 8, 1],
[2, 3, 6],
[7, 5, 9] ];
printUpperTriangular(matrix);
/*
run:
"4 8 1 "
"0 3 6 "
"0 0 9 "
*/