第8题
写出程序运行结果。
classPoint{
intx,y;
Point(intx,inty){
this.x=x;
this.y=y;
System.out.println("父类构造函数被调用!");
}
}
classCircleextendsPoint{
intradius;
Circle(intr,intx,inty){
super(x,y);
this.radius=r;
System.out.println("子类构造函数被调用!");
}
}
publicclasstestInherence{
publicstaticvoidmain(Stringargs[]){
Circlec1=newCircle(2,2,2);
}
}
运行结果:
第9题
下面程序的功能是:根据输入的整数x和n,利用函数fact实现求。 例如:输入:2,3 输出=8 请在程序中的横线上填入正确的内容,将程序补充完整。 /* c7-1.c 利用函数fact实现求x的n次方*/ #include "stdio.h" int main() { long int fact(long x,long n) ; /*声明fact函数*/ long int x ; long int n; printf("please enter X and N(>=0): "); scanf("%ld,%ld", &x, &n ); printf("%ld,%ld=%ld",x,n, (1) ); /*调用fact函数 */ return 0; } long int fact(long int x, long int n) /*定义fact函数求xn */ { long int i,s; (2) ; /*求累积变量的初始化*/ if (n= =0) return 0; for(i=1; i<=n; i++) *用循环实现xn* s="s*x;" (3) ; *返回结果xn*>
第10题
式中:T≥0为时滞常数。在Matlab中提供了命令dde23来直接求解时滞微分方程。其调用格式为801=dde23(ddefun,lags,history,tspan,options),
其中,ddfun为描述时滞微分方程的函数;lags为时滞常数向量;history为描述t≤to时的状态变量值的函数;tspan为求解的时间区间;options为求解器的参数设置。该函数的返回值sol是结构体数据,其中sol.x成员变量为时间向量l,sol.y成员变量为各个时刻的状态向量构成的矩阵,其每一个行对应着一个状态变量的取值。求解如下时滞微分方程组:
已知,在i≤0时,x(t)=5,x2(t)=0,x(1)=1,试求该方程组在[0,40]上的数值解。