mauzil Posted December 31, 2011 Report Share Posted December 31, 2011 Помогите найти ошибку.Получить [ aij ], i = 1, ..., 10; j = 1, ..., 12 - целочисленную матрицу, для которой aij = i + 2j.var a1 = []var max_i = 10;var max_j = 12;for( var i = 1; i <= max_i; i++ ){ a1[ i ] = []; for( var j = 1; j <= max_j; j++ ) a1[ i ][ j ] = i + 2 * i * j;}malert( a1 );var a2 = []for( var i = 1; i <= max_i; i++ ){ a2[ i ] = []; for( var j = 1; j <= max_j; j++ ) if( i < j ) a2[ i ][ j ] = Math.sin( i + j ); else if( i === j ) a2[ i ][ j ] = 1; else a2[ i ][ j ] = Math.asin(( i + j ) / ( 2 * i + 3 * j ))}malert( a2 );function malert( a ){ var s = ''; for( var i = 1; i <= max_i; i++ ) { for( var j = 1; j <= max_j; j++ ) s += a1[ i ][ j ] + '\t'; s += '\n'; } alert( s )} Link to comment Share on other sites More sharing options...
0 s0rr0w Posted December 31, 2011 Report Share Posted December 31, 2011 За тебя школьные задачи порешать? Link to comment Share on other sites More sharing options...
Question
mauzil
Помогите найти ошибку.
Получить [ aij ], i = 1, ..., 10; j = 1, ..., 12 - целочисленную матрицу, для которой aij = i + 2j.
var a1 = []
var max_i = 10;
var max_j = 12;
for( var i = 1; i <= max_i; i++ )
{
a1[ i ] = [];
for( var j = 1; j <= max_j; j++ )
a1[ i ][ j ] = i + 2 * i * j;
}
malert( a1 );
var a2 = []
for( var i = 1; i <= max_i; i++ )
{
a2[ i ] = [];
for( var j = 1; j <= max_j; j++ )
if( i < j )
a2[ i ][ j ] = Math.sin( i + j );
else if( i === j )
a2[ i ][ j ] = 1;
else
a2[ i ][ j ] = Math.asin(( i + j ) / ( 2 * i + 3 * j ))
}
malert( a2 );
function malert( a )
{
var s = '';
for( var i = 1; i <= max_i; i++ )
{
for( var j = 1; j <= max_j; j++ )
s += a1[ i ][ j ] + '\t';
s += '\n';
}
alert( s )
}
Link to comment
Share on other sites
1 answer to this question
Recommended Posts