私は自分のプログラムで立ち往生しています。私は行列を作り、すべてのセルの値を入力し、行列の2つの主対角線の要素の合計を計算する必要があります。 第1の問題 - 私はキーボードで入力する要素で行列を作る方法を見つけることができません。キーボードで数字を入力する方法
<meta charset="windows-1251">
<script>
//10. A real square matrix of size n x n. Calculate the sum of the elements of the two main diagonals of the matrix.
var r,c; //r - rows, c - columns
r = prompt('Enter the number of rows');
c = prompt('Enter the number of columns');
var mat = [];
for (var i=0; i<r; i++){
mat[i] = [];
}
for (var j=0; j<c; j++){
mat[i][j]= prompt ('Enter a value for the cell ' + i + 'x' + j)
}
document.write(' <XMP> ');
document.write('Matrix \t' + mat + '\r');
document.write('</XMP>');
</script>
Thats is it!どうもありがとう! – xLime