阅读以下说明和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( );
}
}
}
第1题:
阅读下列说明和流程图,将应填入(n)处的语句写在对应栏内。
【说明】
下列流程图用泰勒(Taylor)展开式y=ex=1+x+x2/2!+x3/3!+…+xn/n!+…计算并打印ex的近似值,其中用ε(>0)表示误差要求。
【流程图】
第2题:
试题三(共 15 分)
阅读以下说明和 C 程序,将应填入 (n) 处的字句写在答题纸的对应栏内。
第3题:
第4题:
阅读以下说明和JAVA 2代码,将应填入(n)处的字句写在对应栏内。
[说明]
以下程序为类类型的变量应用实例,通过异常处理检验了类CCircle的变量的合法性,即参数半径应为非负值。仔细阅读代码和相关注释,将程序补充完整。
[JAVA代码]
//定义自己的异常类
class CCircleException extends Exception
{
}
// 定义类 CCircle
class CCircle
{
private double radius;
public void setRadius ( double r ) (1)
{
if ( r<0 ) {
(2)
}
else
(3)
}
Public void show ( ) {
System. out. println ( "area="+3.14*radius*radius );
}
}
public class ciusample
{
public static void main ( String args[] )
{
CCircle cir=new CCircle( );
(4) {
cir. setRadius ( -2.0 )
}
(5)
{
System. out. println ( e+" throwed" ) ;
}
cir. show( ) ;
}
}
第5题: