-
阅读以下说明和Java代码,将应填入____处的语句或语句成分写在答题纸的对应栏内。
【说明】某数据文件students.txt的内容为100名学生的学号和成绩,下面的程序将文件中的数据全部读入对象数组,按分数从高到低进行排序后选出排名前30%的学生。【Java代码】
https://assets.asklib.com/psource/2016072810392893550.gif
-
C++程序中,每条语句结束时都加一个分号(;)。
A . 正确
B . 错误
-
阅读下列程序片断: chars[]=”ABCD”,*p=s; cout<有关上述程序的输出结果,正确的判断是()。
A . p[3]引用格式有误,不能输出
B . 输出值不定
C . 输出C
D . 输出D
-
在C++程序中,语句之间必须用()分隔。
-
注释语句可以以Rem开头,这些语句可以放在程序代码的任意位置。
A . 正确
B . 错误
-
对文本文件进行阅读和修改,常使用()程序。
A . A、编辑;
B . B、显示;
C . C、打印;
D . D、连接。
-
阅读下面程序,下列选项中,能够完成语句覆盖的测试用例是() if((x>4)(z<7)) { k=x*y-1; j=sqrt(k); } if((x==8)&&(y>5)) { j=x%y+2; } j=j%3;
A . x=2,y=6,z=5
B . x=6,y=6,z=5
C . x=8,y=6,z=4
D . x=8,y=5,z=5
-
语句测试法中被测试程序每条语句执行一次。
A . 正确
B . 错误
-
C语言程序注释语句的格式是:
-
在 C 程序中,注释说明只能位于一条语句的后面。
-
LINGO程序中注释语句的引导符号是
-
阅读以下程序: 该程序在编译时产生错误,原因是()。A.定义语句出错,Case是关键字,不能用作用户
阅读以下程序:<img src='https://img2.soutiyun.com/ask/uploadfile/3522001-3525000/6b5b0d0d0c1062bd35fa613a06685353.jpg' />该程序在编译时产生错误,原因是()。
A.定义语句出错,Case是关键字,不能用作用户自定义标识符
B.定义语句出错,printF不能用作用户自定义标识符
C.定义语句无错,sCanf不能作为输入函数使用
D.定义语句无错,printf不能输出Case的值
-
阅读下列说明和C++程序,将应填入(n)处的字句写在对应栏内。【程序1说明】 程序1中定义了数组的类模
阅读下列说明和C++程序,将应填入(n)处的字句写在对应栏内。
【程序1说明】
程序1中定义了数组的类模板,该模板使得对于任意类型的二维数组,可以在访问数组元素的同时,对行下标和列下标进行越界判断,并给出相应的提示信息(C++语言本身不提供对下标越界的判断)。
【程序1】
include < iostream. h >
template < class T > class Array2D;
template < class T > class Array2DBody {
friend (1);
T * tempBody;
int iRows, iColumns, iCurrentRow;
Array2DBody(int Rows,int Cols) {
tempBody =(2);
iRows = Rows;
iColumns = Cols;
iCurrentRow = -1;
}
public:
T& operator[ ] (int j){
bool row_ error, column_ error;
row_ error = column_ error = false;
try {
if (iCurrentRow < 0||iCurrentRow > = iRows)
row_ error = true;
if(j < 0||j > = iColumns)
column_error = true;
if(row_error = = true [ [ column_ error = = true)
(3);
}
catch(char) {
if (row_error = = true)
cerr < < "行下标越界"[" < < iCurrentRow < < "]";
if(colmnn_error = = true)
cerr< <"列下标越界[" < <j< <"]";
cout < < "\n";
}
return tempBody[ iCurrentRow * iColumns + j ];
}
~ Array2 DBody () { delete [ ] tempBody; } }; template < class T > class Array2D {
Array2DBody < T > tBody;
public:
Array2DBody < T > & operalor[ ] (int i) {
tBody, iCurreutRow = i;
(4);
Array2D(int Rows,int Cols): (5) {} };
void main()
{
Array2D <int> al (10,20 );
Array2D <double> a2(3,5);
int bl;
double b2;
b1=a1[-5][10];//有越界提示:行下标越界[-5]
b1=a1[10][15];//有越界提示:行下标越界[10]
b1=a1[1][4];//没有越界提示
b2=a2[2][6];//有越界提示:列下标越界[6]
b2=a2[10][20];//有越界提示:行下标越界[10]列下标越界[20]
b2=a2[1][4];//没有越界提示
}
-
阅读以下说明和C++程序,将应填入(n)处的语句写在的对应栏内。 【说明】 以下程序的功能是计算三角形
阅读以下说明和C++程序,将应填入(n)处的语句写在的对应栏内。
【说明】
以下程序的功能是计算三角形、矩形和正方形的面积并输出。
程序由4个类组成:类Triangle、Rectangle和Square分别表示三角形、矩形和正方形;抽象类Figure提供了一个纯虚拟函数getArea(),作为计算上述3种图形面积的通用接口。
【C++程序】
include<iostream.h>
include<math.h>
class Figure {
public:
virtual double getArea()=0; //纯虚拟函数
};
class Rectangle:(1){
protected:
double height;
double width;
public:
Rectangle() {};
Rectangle(double height,double width) {
this->height=height;
this->width=width;
}
double getArea() {
return (2);
}
};
class Square:(3){
public:
Square(double width){
(4);
}
};
class Triangle:(5){
double la;
double lb;
double lc;
Public:
Triangle(double la, double lb, double lc) {
This->la=la; this->lb=lb; this->lc=lc;
}
double getArea() {
double s = (la+lb+±c)/2.0;
return sqrt(s,(s-la)*(s-lb)*(s-Ic));
}
};
void main() {
Figure*figures[3]={
new Triangle(2,3,3), new Rectangle(5,8), new SqUare(5));
for(int i=0;i<3;i++){
cout<<"figures["<<i<<"]area="<<(figures[i])->getArea()<<endl;
}
}
-
阅读下列程序说明和C++代码,将应填入(n)处的字句写在对应栏内。 [说明] ①定义私有数据成员code、en
阅读下列程序说明和C++代码,将应填入(n)处的字句写在对应栏内。
[说明]
①定义私有数据成员code、english分别用于表示考生的编号、英语成绩,它们都是int型的数据。
②完成成员函数void Student::inputinformation()的定义,该函数用于用户输入一个考生对象的信息,输入格式如下:
输入编号:
英语成绩:
计算机成绩:
③利用已实现的类Student的成员函数,完成函数void firstname(Student *A[],int uum)的定义,该函数根据考生信息A[],输出num个考生中总分最高者的编号及其相应的总分,在此不考虑总分相同的情况。
源程序文件test1.cpp清单如下:
include < iostream. h >
class Student
(1)
int computer;
int total;
public
void getinformation();
void computesum();
int getcode();
int gettotalscore();
~Student();
};
void Student: :getinformation()
{
(2)
cout <<"英语成绩:";
cin> >english;
cout <<"计算机成绩:";
cin > > computer;
void Student:: computesum ()
total = english + computer;
cout <<"编号" << code <<"总分:" <<total << endl;
int Student::getcode()
return code;
}
int Student:: gettotalscore ()
{
return total;
}
void firstname(Student * A[] ,int num)
{
(3)
tempsum = (* A[0] ). gettotalscore();
for(int i=1; i <num; i++)
{
if (((* A[i] ). gettotalscore() ) > tempsum)
{
tempcode = (* A[i] ). getcode();
tempsum = (* A[i] ). gettotalscore();
}
}
cout <<"总分最高者--" << tempcode <<":" << tempsum <<endl;
}
void main()
{
Student * A[3];
int i,n =3
for(i=0;i<n;i ++)
A[i] = new Student;
A[i] -> getinformation()
for(i=0;i<n;i ++)
{
A[i] -> computesum()
firstname (A,3 );
}
-
阅读以下说明和C++程序,将应填入(n)处的字句写在对应栏内。【C++程序】include < stdio. h >include
阅读以下说明和C++程序,将应填入(n)处的字句写在对应栏内。
【C++程序】
include < stdio. h >
include < string. h >
define Max 1000
class Bank
{
int index;
char date [Max] [10]; // 记录交易日
iht amount[Max]; // 记录每次交易金额,以符号区分存钱和取钱
int rest[ Max]; // 记录每次交易后余额
static iht sum; // 账户累计余额
public:
Bank() {index =0;}
void deposit(char d[ ] , int m) //存入交易
{
strcpy (date [ index ], d);
amount[ index] = m;
(1);
rest[ index] = sum;
index++;
}
void withdraw (char d[ ], int m) //取出交易
{
strcpy(date[ index] ,d);
(2);
(3);
rest[ index] = sum;
index++;
}
void display();
};
int Bank:: sum = 0;
void Bank:: display () //输出流水
{
int i;
printf("日期 存入 取出 余额\n");
for (4)
{
printf(" %8s" ,date[i] );
if (5)
printf(" %6d" , -amount[i] );
else
printf("%6d ",amount[i] );
printf("% 6d\n" ,rest[i] );
} }
void main()
{
Bank object;
object. deposit ("2006.2.5", 1 00 );
object. deposit("2006.3.2" , 200);
object. withdraw("2006.4.1", 50);
object. withdraw("2006.4.5", 80);
object. display ();
}
本程序的执行结果如下:
日期 存入 取出 余额 2006.2.5 100 100
2006.3.2 200 300
2006.4.1 50 250
2006.4.5 80 170
-
C++程序中,每条语句结束时都加一个分号";"。()
是
否
-
阅读下列程序:程序运行后,单击命令按钮后的输出结果是()
A.234
B.345
C.567
D.356
-
阅读下面的程序,按要求在空白处填写适当的表达式或语句,使程序完整并符合题目要求。已知下面程序的功能是:从键盘任意输入一个年号,判断它是否是闰年。若是闰年,输出“Yes”; 否则输出“No”, 已知符合下列条件之一者是闰年:(1) 能被4整除, 但不能被100整除;
(2)能被400整除。
<img src='https://img2.soutiyun.com/ask/2020-12-03/9758576894666.png' />
-
9、Python程序中每条语句以分号结尾。
-
对程序语句的注释文字必修放在()之后,或者放在()之内。
A.//双斜杠 、 /*......*/
B.//双斜杠 、 ;分号
C.//双斜杠 、 /单斜杠
D./*......*/
-
【单选题】阅读下面程序,则disp语句所显示结果为()。 x=1; while x~=5 disp(x) x=x+1; end
A.1 3 2 4
B.1 2 3 4
C.2 3 4 5
D.1 3 4 2
-
6、C语言程序中“//”作为语句的 ,注释部分内容程序不进行编译。
-
(专基)阅读程序,语句a=a+10执行的次数是()。 void main(){ int x=8,a=1;do{a=a+10;} while (x>0); }
A.0
B.1
C.无限次
D.有限次
此题为多项选择题。