| var Transpose_Matrix = (function () { function Transpose_Matrix() { } Transpose_Matrix.prototype.matrix = function () { var matrix = [ [ 20 ], [ 20 ] ]; var transpose = [ [ 20 ], [ 20 ] ]; var i; var j; var m; var n; document.write("<h2>Transpose Matrix in TypeScript</h2><hr>"); m = parseInt(prompt("Enter the number of Rows of Matrix")); n = parseInt(prompt("Enter the number of Columns of Matrix")); document.write("<b>1st Matrix Elements :"); for(i = 0; i < m; i++) { for(j = 0; j < n; j++) { matrix[i][j] = parseInt(prompt("Enter the element of First Matrix -> Row " + (i) + " And Coloumn " + (j))); } document.write("<br> "); } for(i = 0; i < m; i++) { for(j = 0; j < n; j++) { document.write(" " + matrix[i][j]); } document.write("<br> "); } document.write("<br>"); document.write("Transpose of Entered Matrix :"); for(i = 0; i < m; i++) { for(j = 0; j < n; j++) { transpose[j][i] = matrix[i][j]; } } document.write("<br> "); for(i = 0; i < n; i++) { for(j = 0; j < m; j++) { document.write(" " + transpose[i][j]); } document.write("<br> "); } }; return Transpose_Matrix; })(); window.onload = function () { var tramatrix = new Transpose_Matrix(); tramatrix.matrix(); }; |