题目
A.2
B.4
C.6
D.3
第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 <iostream> #include <fstream> using namespace std; int main () { ofstream ofile; char ch; ofile.open ("abc.txt"); cin>>ch; while (ch!='#' ) { cin>>ch; ofile.put(ch);
A.程序编译时出错
B.abc#
C.abc
D.#
第9题
有以下程序
#include <stdio.h>
#include <string.h>
main()
{ printf("%d\n",strlen ("ATS\n012\1") ); }
程序运行后的输出结果是
A)3
B)8
C)4
D)9
第10题
A.10
B.20
C.0
D.出错
第11题
有以下程序:
include<stdio.h>
include<strin9.h>
main()
{printf{"%d\n",strlen("%d\n",strlen("ATS\n012\|"));}
程序运行后的输出结果是()。
A.3
B.8
C.4
D.9
为了保护您的账号安全,请在“赏学吧”公众号进行验证,点击“官网服务”-“账号验证”后输入验证码“”完成验证,验证成功后方可继续查看答案!