题目
有以下程序#include <string.h>struct STU{ int num; float TotalScore; };void f(struct STU p){ struct STU s[2]={{1047,530},{1048,531}}; p.num = s[1].num; p.TotalScore = s[1].TotalScore;}main(){ struct STU s[2]={{2041,730},{2042,731}}; f(s[0]); printf("%d,%3.0f\n",s[0].num,s[0].TotalScore);}程序的运行结果是A.1047,530 B.1048,531C.2041,730 D.2042,731
第1题
如下程序声明了一个二维图形类TwoDShape,从其派生出矩形类Rec。
include<iostream>
include<string>
using namespaee std,
class TwoDShape{// 二维图形类
char name[20];
public:
TwoDShape (char * n="unknown") {
strcpy(name, n);
}
Char * getName(){return name;}
【 】=0;
};
class Rec: public TwoDShape{
double width, height
public:
Rec(double w-=0. 0,double h=0. 0):TwoDShape("rectangle")
{ width=w; height=h; }
double getWidth() {return width;}
double getHeight() {return height;}
double area() {return width * height;}
};
int main() {
TwoDShape * shape;
Shape=new Rec(2.1,3.0);
cout<<"object is"<<shape->getName()<<"\n";
cout<<"Area is"<<shape->area()<<"\n";
return 0
}
请将程序补充完整,使程序在运行时输出:
abject is triangle
Area is 6.3
第2题
注意:请勿改动main()主方法和其他已有语句内容,仅在下划线处填入适当的语句。
程序运行结果如下:
import javax.swing. JOptionPane;
public class ex10_2 {
public static void main(String[] args) (
String strIn;
int nYear,nMonth,nNumOfDays=0;
strIn=JOptionPane.showInputDialog(,,year.);
nYear=Integer.parseInt(strIn);
if(nYear<0) {
System.out.println("Invalidate number of year!")
return;
} strIn=JOptionPane.showInputDialog("month.);
nMonth=Integer.parseInt(strIn);
if(_____________) {
System.out.println("Invalidate number of month!"
return;
}
switch(nMonth){
case 1:
case 3:
case 5:
case 7:
case 8:
case 10:
case 12:
nNumOfDays=31;
break;
case 4:
case 6:
case 9:
case 11:
nNumOfDays=30;
break;
case 2:
if(________________)
nNumOfDays=29;
else
nNumOfDays=28;
break;
}
System.out.println("Number of days:"+ nNumOfDays);
}
}
第3题
有以下程序:
# include< iostream>
执行这个程序,输出结果是()。
第7题
有以下程序
#include <stdio.h>
#include <string.h>
main()
{ printf("%d\n",strlen ("ATS\n012\1") ); }
程序运行后的输出结果是
A)3
B)8
C)4
D)9
第8题
第9题
A.Tom,Jerry,Donald
B.Tuffy,Jerry,Donald
C.Tuffy,Tuffy,Tuffy
D.发生异常,输出异常信息
第10题
A.10
B.20
C.0
D.出错
第11题
有以下程序
#include<stdio.h>
#include<string.h>
main()
{char a[10]=”abcd”;
prinff(“%d,%d\n”,strlen(A),sizeof(A));
}
程序运行后的输出结果是
A.7,4
B.4,10
C.8,8
D.10,lO
为了保护您的账号安全,请在“赏学吧”公众号进行验证,点击“官网服务”-“账号验证”后输入验证码“”完成验证,验证成功后方可继续查看答案!