• 游客 购买了资源 2024年秋云南开放大学大学英语3在线作业3
  • u******* 下载了资源 国开学习网电大《计算机网络(本)》形考作业四答案
  • u******* 购买了资源 国开学习网电大《计算机网络(本)》形考作业四答案
  • u******* 登录了本站
  • u******* 登录了本站
  • u******* 签到打卡,获得1金币奖励
  • a******* 下载了资源 爱普生Epson L6160 驱动
  • a******* 下载了资源 爱普生Epson L6160 驱动
  • a******* 购买了资源 爱普生Epson L6160 驱动
  • a******* 下载了资源 2024年春江苏开放大学工程制图与CAD△060239过程性考核作业4

福建省开课平台7398c++语言程序设计形考1-3参考答案

本课程题目顺序随机,请使用Ctrl+F搜索

1.在下面的二维数组定义中,只有(    )语句是正确的。
A.      int a[5][];         B.      int a[](10);         C.      int a[][];         D.      int a[][5]={{1,2,3},{4,5}};
【答案】:D

2.假定AB为一个类,px为指向该类动态对象数组的指针,该数组长度为n,则执行“delete px;”语句时,自动调用该类析构函数的次数为(    )。
A.      1         B.      n         C.      n-1         D.      n+1
【答案】:B

3.当需要使用ifstream流类定义一个流对象并联系一个磁盘文件时,应在文件开始使用#include命令,使之包含(    )头文件。
A.      strstrea.h         B.      stdlib.h         C.      iostream.h          D.      fstream.h
【答案】:D

4.在下面的一维数组定义中,(    )语句有语法错误。
A.      int a[]={1,2,3};         B.      int a[10]={0};         C.      int a[];         D.      int a[5];
【答案】:C

5.假定a为一个数组名,则下面的(    )表达式有语法错误。
A.      a         B.      *++a         C.      *a         D.      *(a+1)
【答案】:

6.在下面的函数声明中,存在着语法错误的是(    )。
A.      BC(int a, int)          B.      BC(int, int)         C.      BC(int, int=5)         D.        BC(int x=6, int y)
【答案】:

7.假定有结构定义为“struct BOOK{char title40; double price;};”,则该结构类型的长度为(    )个字节。
A.      28         B.      40         C.      44         D.      48
【答案】:

8.

当一个字符指针指向具有n个字节的存储空间时,它所能存储字符串的最大长度为(    )。
A.      n         B.      n+1         C.      n-1         D.      n-2
【答案】:

9.下面(    )的函数声明格式不正确。
A.      AA(int a, int b);         B.      AA(int a=0, int b);         C.      AA(int a=0, int b=0);         D.      AA(int a, int b=0);
【答案】:

10.下面的保留字(    )不能作为函数的返回类型。
A.      void         B.      int         C.      new         D.      long
【答案】:

11.设x是一个bool型的逻辑量,y的值为10,则表达式 x && y的值为(    )。
A.      1         B.      0         C.      x的值         D.      x的相反值
【答案】:

12.在下列的标识符常量的定义语句中,错误的定义语句是(    )。
A.      const double PI=3.14159;         B.        const int N=20;          C.      const char ch;          D.        const bool mark=true;
【答案】:

13.下面的函数声明中,(    )是“void BC(int a, int b);”的重载函数。
A.      int BC(int x, int y);         B.      void BC(int a, char b);         C.      float AA(int a, char b);         D.      int BC(int a, int b=0);
【答案】:

14.假定指针变量p定义为“int *p=new int30;”,要释放p所指向的动态数组空间,则使用下面的(    )语句。
A.      delete p;         B.      delete *p;         C.      delete &p;         D.      delete []p;
【答案】:

15.for循环语句一定能够被改写为(    )语句。
A.      复合         B.      if         C.      switch         D.      while
【答案】:

16.设x和y均为bool量,则逻辑表达式x || y为假的条件是(    )。
A.      x和y均为真         B.      其中一个为真         C.      x和y均为假         D.      其中一个为假
【答案】:

17.假定AB为一个类,则该类的拷贝构造函数的声明语句为(    )。
A.      AB&(AB x);         B.      AB(AB x);         C.      AB(AB* x);          D.      AB(AB&);
【答案】:

18.下面的(    )保留字不能作为函数的返回类型。
A.      void         B.      int         C.      new         D.      long
【答案】:

19.break语句叫做(    )语句。
A.      中断退出循环或开关         B.      返回         C.      转向         D.      继续
【答案】:

20.程序运行中需要从键盘上输入多于一个数据时,各数据之间需要使用(    )符号作为分隔符。
A.      空格或逗号         B.      逗号或回车         C.      逗号或分号         D.      空格或回车
【答案】:

21.由C++源程序文件编译而成的目标文件的缺省扩展名为(    )。
A.      obj          B.      lik         C.      exe         D.      cpp
【答案】:

22.C++编译预处理命令在程序中都是以(    )字符开头的。
A.      *         B.      #         C.      &         D.      @
【答案】:

23.声明或定义一个内联函数时,必须在函数开始使用保留字(    )。
A.      static         B.      const         C.      extern         D.      inline
【答案】:

24.将两个字符串连接起来组成一个字符串时,选用(    )函数。
A.      strlen()         B.      strcpy()         C.      strcat()         D.      strcmp()
【答案】:

25.枚举类型中的每个枚举常量的值都是一个(    )值。
A.      整数         B.      浮点数         C.      字符         D.      逻辑
【答案】:

26.

假定要对结构类型AB定义加号运算符重载的普通函数,实现两个AB类型对象的加法,并返回相加结果,则该函数的声明语句为(    )。
A.       AB operator +(AB& a, AB& b);         B.        AB operator +(AB& a);          C.      operator +(AB a);          D.      AB& operator +();
【答案】:

27.假定a为一个整型数组名,则元素a4与(    )的表示等价。
A.      a+4         B.      *a+4         C.      *(a+4)         D.      *(a+16)
【答案】:

28.

C++源程序文件的默认扩展名为(    )。
A.      cpp         B.      exe         C.      obj          D.      lik
【答案】:

29.

循环语句“for(int i=0; i<n; i++);”执行结束后得到的i的值为(    )。
A.      n         B.      n+1         C.      n-1         D.      2n
【答案】:

30.任何for语句都能够被改写为(    )语句。
A.      复合         B.      if         C.      switch         D.      while
【答案】:

31.

写出下列每个程序运行后的输出结果

#include<iostream.h>

void main() {

int n=5, sum=0;

while(n) {

sum+=n;

n–;

}

cout<<”sum=”<<sum<<endl;

}
【答案】:

32.

写出下列每个程序运行后的输出结果

#include<iostream.h>

#include<stdlib.h>

void main() {

int x=20, y=6, z;

char op=’+’;

switch(op) {

case ‘+’: z=x+y; break;

case ‘-‘: z=x-y; break;

default: {cout<<“操作符op出错,退出运行!”;exit(1);}

}

cout<<”z=”<<z<<endl;

}

【答案】:

33.

写出下列每个程序运行后的输出结果

#include<iostream.h>

int WF(int x, int y) {

x=x+y;

y=x+y;

return x+y;

}

void main() {

cout<<WF(8,5)<<endl;

}
【答案】:

34.

写出下列每个程序运行后的输出结果

#include<iostream.h>

void main() {

int n=5, sum=0;

while(n) {

sum+=n*n;

n–;

}

cout<<“sum=”<<sum<<endl;

}
【答案】:

35.

写出下列每个程序运行后的输出结果

#include<iomanip.h>

int* LG(int m) {

int* a=new int(m+5);

return a;

}

void main() {

int n1=12;

int *b=LG(n1);

cout<<*b<<endl;

delete b;

}
【答案】:

36.

写出下列每个程序运行后的输出结果

#include<iomanip.h>

int LA(int a, int n) {

int s=0;

for(int i=0;i<n;i++)

s+=ai;

return s;

}

void main() {

int a5={5,2,8,6,4};

int b=LA(a,5);

cout<<“b=”<<b<<endl;

}
【答案】:

37.

写出下列每个程序运行后的输出结果

#include<iostream.h>

int a=10, b=15, c;

void main() {

c=a+b;

{ int b=a+20;

c+=a+b;

}

cout<<c<<endl;

}
【答案】:

38.

写出下列每个程序运行后的输出结果

#include<iostream.h>

const int N=6;

void main() {

int aN={76,83,54,62,40,65};

int c1, c2;

c1=c2=a0;

for(int i=1;i<N;i++)

if(ai>c1) c1=ai;

else if(ai<c2) c2=ai;

cout<<c1<<‘ ‘<<c2<<endl;

}
【答案】:

39.

写出下列每个程序运行后的输出结果

#include<iostream.h>

#include<string.h>

struct Worker {

char name15; int age; float pay;

};

void main() {

Worker x;

strcpy(x.name, “WeiRong”);

x.age=45; x.pay=3275;

cout<<x.name<<‘ ‘<<x.age<<‘ ‘<<x.pay<<endl;

}
【答案】:

40.

写出下列每个程序运行后的输出结果

#include<iostream.h>

void main() {

int a6={6,9,12,18,15,20};

int c=0;

for(int i=0; i<6; i++)

if(ai%2==1) c++;

cout<<“c=”<<c<<endl;

}
【答案】:

41.

写出下列每个程序运行后的输出结果

#include<iomanip.h>

void main() {

int a5={3,6,9,12,8};

for(int *p=a; p<a+5; p++)

if(*p>8) cout<<*p<<‘ ‘;

}
【答案】:

42.

写出下列每个程序运行后的输出结果

#include<iomanip.h>

const int N=9;

void main() {

int aN={2,4,6,8,10,12,14,16,18};

int s=0;

for(int i=0; i<N; i++) {

if(ai%3==0) s+=ai;

}

cout<<”s=”<<s<<endl;

}
【答案】:

43.

写出下列每个程序运行后的输出结果

#include<iostream.h>

void main() {

int i=1,s=0;

while(s<15) s+=i++;

cout<<i<<‘,'<<s<<endl;

}
【答案】:

44.

写出下列每个程序运行后的输出结果

#include<iostream.h>

class A {

int a,b;

public:

A() {a=b=0;}

A(int aa, int bb) {

a=aa; b=bb;

cout<<a<<‘ ‘<<b<<endl;

}

};

void main() { A x,y(3,4);}
【答案】:

45.

写出下列每个程序运行后的输出结果

#include<iomanip.h>

int LB(int *a, int n) {

int p=1;

for(int i=0;i<n;i++) {

p*=*a; a++;

}

return p;

}

void main() {

int a5={1,2,3,4,3};

cout<<LB(a,5)<<endl;

}
【答案】:

46.

写出下列每个程序运行后的输出结果

#include<iostream.h>

void main() {

int a34={{1,2,7,8},{5,6,11,15},{9,20,3,4}};

int m=a00;

for(int i=0;i<3;i++)

for(int j=0;j<4;j++)

if(aij>m) m=aij;

cout<<m<<endl;

}
【答案】:

47.

写出下列每个程序运行后的输出结果

#include<iostream.h>

void SB(char ch) {

switch(ch) {

case ‘A’: case ‘a’: cout<<“优!”<<’ ’; break;

case ‘B’: case ‘b’: cout<<“良!”<<’ ’; break;

case ‘C’: case ‘c’: cout<<“通过!”<<’ ’; break;

default: cout<<“不通过!”;break;

}

}

void main() {

SB(’A’); SB(’c’);

cout<<endl;

}
【答案】:

48.

写出下列每个程序运行后的输出结果

#include<iostream.h>

#include<string.h>

void main() {

char* a5={“student”,”worker”,”cadre”,”soldier”,”apen”};

unsigned int n=strlen(a0);      //求字符串a0的长度

for(int i=1;i<5;i++) {

if(strlen(ai)>n) n=strlen(ai);

}

cout<<n<<endl;

}
【答案】:

49.

写出下列每个程序运行后的输出结果

#include<iomanip.h>

void main() {

int a8={4,8,15,16,20,30,48,62};

int *p=a,s=0;

while(p<a+8) {

s+=*p;

p+=3;

}

cout<<s<<endl;

}
【答案】:

50.

写出下列每个程序运行后的输出结果

#include<iostream.h>

void FF(int a, int n) {

int i,x;

for(i=0; i<n/2; i++) {

x=ai; ai=an-1-i; an-1-i=x;

}

}

void main() {

int a8={6,19,4,12,20,5,18,25};

FF(a,8);

cout<<a0<<‘,'<<a1<<endl;

}
【答案】:

51.

写出下列每个程序运行后的输出结果

#include<iomanip.h>

void main() {

int a8={4,8,15,16,20,30,48,62};

int *p=a;

while(p<a+8) {

cout<<*p<<‘ ‘;

p+=3;

}

cout<<endl;

}
【答案】:

52.

写出下列每个程序运行后的输出结果

#include<iostream.h>

const int N=6;

void main() {

int aN={76,83,54,62,40,65};

int c1=0;

for(int i=0;i<N;i++)

if(ai>=60) c1++;

cout<<“c1=”<<c1<<endl;

}
【答案】:

53.

写出下列每个程序运行后的输出结果

#include<iostream.h>

void main() {

int s1=0;

for(int i=1; i<=5; i++) s1+=2*i;

cout<<”s1=”<<s1<<endl;

}
【答案】:

54.

写出下列每个程序运行后的输出结果

#include<iostream.h>

void main() {

int s=0;

for(int i=1;i<=8;i+=2)

s+=i*i;

cout<<“s=”<<s<<endl;

}
【答案】:

55.

写出下列每个程序运行后的输出结果

#include<iostream.h>

void main() {

int a8={36,25,48,14,55,20,47,82};

int c1=0, c2=0;

for(int i=0; i<8; i++)

if(ai<50) c1++; else c2++;

cout<<c1<<‘ ‘<<c2<<endl;

}
【答案】:

56.

写出下列每个程序运行后的输出结果

#include<iostream.h>

void main() {

int n=4,y=1;

while(n–) y*=3;

cout<<“y=”<<y<<endl;

}
【答案】:

57.

写出下列每个程序运行后的输出结果

#include<iostream.h>

void main() {

int a6={36,25,48,14,55,40};

int x=a0;

for(int i=1;i<6;i++)

if(ai>x) x=ai;

cout<<”x=”<<x<<endl;

}
【答案】:

58.

写出下列每个程序运行后的输出结果

#include<iomanip.h>

void main()

{

int a6={32,53,27,19,12,45};

for(int *p=a; p<a+6; p++)

if(*p%3==0) cout<<*p<<’ ’;

cout<<endl;

}
【答案】:

59.

写出下列每个程序运行后的输出结果

#include<iomanip.h>

int LF(int x, int y) {

x=x+y; y=x+y;

return x+y;

}

void main() {

int x=5, y=8;

cout<<LF(1,2)<<‘ ‘<<LF(3,4)<<endl;

}
【答案】:

60.

写出下列每个程序运行后的输出结果

#include<iomanip.h>

void main() {

int* d=new int5;

int i,s=0;

for(i=0;i<5;i++) di=2*i+1;

for(i=0;i<5;i++) s+=di;

cout<<3*s<<endl;

deleted;

}
【答案】:

61.

写出下列每个程序运行后的输出结果

#include<iomanip.h>

struct AB {

char aa15;

int bb;

};

void main() {

AB a4={{“Apple”,25},{“Peach”,40},{“Pear”,36},{“Tomato”,62}};

for(int i=0;i<4;i++)

if(ai.bb<40) cout<<ai.aa<<‘ ‘;

cout<<endl;

}
【答案】:

62.

写出下列每个程序运行后的输出结果

#include<iostream.h>

void main() {

int a8={2,8,10,5,12,7,9,20};

int c=0, i=0;

while(i<8) {

if(ai>10) c++;

i++;

}

cout<<“c=”<<c<<endl;

}
【答案】:

63.

写出下列每个程序运行后的输出结果

#include<iostream.h>

void main() {

int a8={6,19,4,12,20,5,18,25};

int *p, s=0;

for(p=a; p<a+8;p++)

if(*p<10) s+=*p;

cout<<s<<endl;

}
【答案】:

64.

写出下列每个程序运行后的输出结果

#include<iostream.h>

void main() {

int a=10, b=15, c;

c=a+b;

{ int b=a+20;

c+=a+b;

}

cout<<c<<endl;

}
【答案】:

65.

写出下列每个程序运行后的输出结果

#include<iostream.h>

struct Worker {

char name15;  //姓名

int age;        //年龄

float pay;      //工资

};

void main() {

Worker x={“wangfong”,46,1640};

Worker y, *p;

y=x; p=&x;

cout<<y.age+10<<‘ ‘<<p->pay*2<<endl;

}
【答案】:

66.

int SA(int a, int b) {

if(a>b) return 1;

else if(a==b) return 0;

else return -1;

}

函数功能:
【答案】:

67.

bool WB(int a, int n, int x) {

for(int i=0;i<n;i++)

if(ai==x) return true;

return false;

}

函数功能:
【答案】:

68.

bool SG(int x) {        //x为大于等于2的整数

int a=int(sqrt(x));  //sqrt(x)为求x的平方根

int i=2;

while(i<=a) {

if(x%i==0) break;

i++;

}

if(i<=a) return true; else return false;

}

函数功能:
【答案】:

69.

double WA(double a, int n) {

double s=0;

for(int i=0;i<n;i++) s+=ai;

return s/n;

}

函数功能:
【答案】:

70.

double FI(int n) {     //n为大于等于1的整数

double x,y=0;

do {

cin>>x;

y+=x;

} while(–n);

return y;

}

函数功能:
【答案】:

71.

int LK(int a, int n) {

double s=0;

int i,m=0;

for(i=0;i<n;i++) s+=ai;

s=s/n;

for(i=0;i<n;i++) if(ai>=s) m++;

return m;

}

函数功能:
【答案】:

72.

int LK(int a, int n) {

float s=0; int i;

for(i=0;i<n;i++) s+=ai;

s/=n;

int m=0;

for(i=0;i<n;i++) if(ai>=s) m++;

return m;

}

函数功能:
【答案】:

73.

int LJ(int a, int n) {

int k=0;

for(int i=1;i<n;i++)

if(ai>ak) k=i;

return ak;

}

函数功能:
【答案】:

74.

int WC(int a, int n, int k) {

int c=0;

for(int i=0;i<n;i++)

if(ai>=k) c++;

return c;

}

函数功能:
【答案】:

75.

double FI(double n) {    //n为大于等于1的整数

double x,y=0;

for(int i=0; i<n; n++) {

cin>>x; y+=x;

}

return y;

}

函数功能:
【答案】:

76.

假定结构类型DNode中的data域为结点值域,next域为结点指针域。

void QB(DNode *f)    //f指向单链表的表头结点

{

if(f==NULL) return;

while(f!=NULL) {

cout<<f->data<<‘ ‘;

f=f->next;

}

}

函数功能:
【答案】:

77.

假定结构类型Worker中的name域表示姓名,age域表示年龄,pay域表示工资。

void QA(Worker a, int n) {

for(int i=0; i<n; i++)

cin>>ai.name>>ai.age>>ai.pay;

}

函数功能:
【答案】:

78.

bool WE(int a, int b, int n) {

for(int i=0;i<n;i++)

if(ai!=bi) break;

if(i==n) return true; return false;

}

函数功能:
【答案】:

79.

int WG(int a, int b) {

if(a>0 && b>0) return 1;

else if(a<0 && b<0) return -1;

else return 0;

}

函数功能:
【答案】:

80.

double FI(int n) {     //n为大于等于1的整数

double x,y=0;

do {

cin>>x;

y+=x*x;

} while(–n);

return y;

}

函数功能:
【答案】:

81.

int SC(int a, int b, int c) {

if(a>b) a=b;

if(a>c) a=c;

return a;

}

函数功能:
【答案】:

82.

假定结构类型StrNode带有一个字符串域name20和一个结点指针域next。

int QB(StrNode* f) {      //f为单链表的表头指针

if(f==NULL) return 0

int n=0;

while(f!=NULL) {n++; f=f->next;}

return n;

}

函数功能:
【答案】:

83.

int WD(int a, int n) {

int m=a0;

for(int i=1;i<n;i++)

if(ai>m) m=ai;

return m;

}

函数功能:
【答案】:

84.

int LK(int a, int n) {

double s=0;

int i,m=0;

for(i=0;i<n;i++) s+=ai;

s=s/n;

for(i=0;i<n;i++) if(ai>=s) m++;

return m;

}

函数功能:
【答案】:

内容查看
查看价格15
点点赞赏,手留余香 给TA打赏

AI创作

课程作业辅导,点击图片加微信,有偿服务

评论0

请先
支持多种货币
支持多种货币付款,满足您的付款需求
7天无忧退换
安心无忧购物,售后有保障
专业客服服务
百名资深客服7*24h在线服务
发货超时赔付
交易成功极速发货,专业水准保证时效性
显示验证码

社交账号快速登录

微信扫一扫关注
扫码关注后会自动登录