网友您好, 请在下方输入框内输入要搜索的题目:
阅读以下说明和Java 码,将应填入(n)处的字名写在的对应栏内。
[说明] 打印输出10行杨晖三角形。形式如下:
杨晖三角形:
1
1 1
1 2 1
1 3 3 1
1 4 6 4 1
1 5 10 10 5 1
1 6 15 20 15 6 1
1 7 21 35 35 21 7 1
1 8 28 56 70 56 28 8 1
1 9 36 84 126 126 84 36 9 1
class yanghui
{
public static void main (String args [] )
{
int i, j;
(1)
int yanghui [] [];
System. out. println( “杨晖三角形:” );
yanghui = new int [ yhleve1] [];
for(i =0;i < yanghui, length; i + + )
yanghui[i] = new int [i + 1];
(2)
for((3))
{
yanghui [i] [0] = 1;
for(j = 1 ;j < yanghui[i], length - 1 ;j + + )
yanghui[i] [j] = yanghui[i - 1] [j - 1] + yanghui[i - 1] [j];
yanghui[i] [yanghui[i]. length - 1 ] = 1;
}
for ( i=0; i < yanghui. length; i + + )
{
for(j =0;j < yanghui[i]. length; j + + )
(4)
System. out. println( );
}
}
}
参考答案