面向对象程序设计基础(内蒙古工业大学)1454215178 中国大学MOOC答案100分完整版

面向对象程序设计基础(内蒙古工业大学)1454215178 中国大学MOOC答案100分完整版

甸狸绷猩澎酥琅虹乾犁锑判灌

第1章——初识C++语言从认识变量和常量开始,数据的表示

第一章单元测试

1、单选题:
‍以下关于C++语言描述错误的是()‌

A: 一个C++程序总是从main函数开始执行
B: 每个语句和数据声明的最后必须有一个分号
C: C++语言的注释符是以“/*”开始并以“*/”结束的       
D: 一个C++程序可以包含多个main函数
答案:  一个C++程序可以包含多个main函数

2、单选题:
‌C++ 语言源程序文件后缀为(    )。‍

A: .EXE   
B:  .OBJ        
C: .cpp             
D:  .ASM
答案:  .cpp             

3、单选题:
‍C++语言是(    )‏

A: 机器语言
B: 汇编语言
C: 仅具有面向对象特征的语言
D:  既表现面向对象的特征,又表现面向过程的特征
答案:   既表现面向对象的特征,又表现面向过程的特征

4、单选题:
​C++语言中普通整型变量int在内存中占(   )字节。‌

A: 1
B: 2
C: 3
D: 4
答案:  4

5、单选题:
‍下列不是C++语言基本数据类型的是 (    )。‍

A: 字符型
B: 整型
C: 浮点型
D: 结构体
答案:  结构体

6、单选题:
​各种基本数据类型的存贮空间正确的长度排列为(        )。‎

A: int < char <double 
B: double <int<char
C: char<int <double    
D: int <=char<double
答案:  char<int <double    

7、单选题:
‌下面的变量说明中(       )是正确的。‏

A:  char:a, b, c; 
B: char a; b; c;   
C: char a, b, c;  
D:  char a, b, c。
答案:  char a, b, c;  

8、单选题:
‏转义字符“反斜杠线”的表示方法正确的是(        ) 。​

A:          
B: \        
C: ‘’     
D: “”
答案:  \        

9、单选题:
‍在C++语言中,自定义的标识符(      )。‌

A: 能使用关键字并且不区分大小写 
B: 不能使用关键字并且不区分大小写
C: 能使用关键字并且区分大小写  
D: 不能使用关键字并且区分大小写
答案:  不能使用关键字并且区分大小写

10、单选题:
字符串“a+b=12nt”占的字节数为(    )  ​​

A: 8
B: 9
C: 10
D: 11
答案:  9

第2章——计算从数据运算开始,数据简单运算

第二章单元测试

1、单选题:
执行下面程序段的输出结果是(     )。‌int x=23, y=5,z;‌z=2+(y++,x+8,x++); ‌‍    cout<<x<<”   “<<z<<endl;‌

A: 24    25
B: 24  26
C: 25  26
D: 25  25 
答案:  24    25

2、单选题:
​若int型变量x=29,double型变量y=6.0,则表达式x/y的值为(     ) 。‎

A: 4.83333
B: 4
C: 5
D: 5.0
答案:  4.83333

3、单选题:
‍ 判断字符型变量ch是否为大写英文字母,应使用表达式(   )。​

A:  ch>=’A’ & ch<=’Z’
B: ch<=’A’ ||ch>=’Z’
C: ‘A'<=ch<=’Z’
D: ch>=’A’ && ch<=’Z’
答案:  ch>=’A’ && ch<=’Z’

4、单选题:
int x=5, y=6;下列表达式结果为真的是(    ) 。‍

A: x==y– 
B: x==++y 
C: x++==y   
D: x==–y
答案:   x==–y

5、单选题:
设有a、b、c、d、m、n均为int型变量,且a=5、b=6、c=7、d=8、m=2、n=2,‎则逻辑表达式(m=a>b)&&(n=c>d)运算后,n的值为(   )‎

A: 0
B: 1
C: 2
D: 3
答案:  2

6、单选题:
执行下列语句后,输出的结果是(   ).‍int a=3,b=5;‍double c=b/a;‍cout<<c<<endl;‍

A: 1.66666
B: 1
C: 1.0
D: 1.7
答案:  1

7、单选题:
已知int x=5,y=5,z=5;执行语句x%=y+z;后,x的值是(     )。‎

A: 5
B: 6
C: 0
D: 1
答案:  5

8、单选题:
逗号表达式a=3,a++,a+=6的值是(     )。​

A: 10
B: 9
C: 11
D: 12
答案:  10

9、单选题:
 已知下列语句中的x和y都是int型变量,其中错误的语句(    )。‏

A: x=y++;
B: x=++y;
C: (x+y)++;
D: ++x==y;
答案:  (x+y)++;

10、单选题:
执行以下代码后,变量x、y、z的值分别为()‏int x=1,z=1,y=1,k;‏k=x++||++y&&++z‏

A: 2 1 1
B: 2 2 2
C: 1 2 2
D: 1 1 2
答案:  2 1 1

第3章——分支结构无处不在的抉择

第三章单元测试

1、单选题:
执行语句序列‍int n;‍cin >> n;‍switch(n)‍{     case 1:‍      case 2: cout << ‘1’;‍      case 3:‍      case 4: cout << ‘2’; break;‍default: cout << ‘3’;‍}‍‍时,若键盘输入1,则屏幕显示(    )。‍

A: 1
B: 2
C: 3
D: 12
答案:  12

2、单选题:
下面程序的输出结果是(   ).‏#include<iostream>‏using namespace std;‏int main()‏{‏int a=2,b=-1,c=2;‏if (a<b)‏  if (b<0) c=0;‏else c+=1;‏cout <<c<<endl;‏return 0;‏}‏

A: 0
B: 1
C: 2
D: 3
答案:  2

3、单选题:
为了避免嵌套的if-else语句的二义性,C++语言规定else总是与(   )组成配对关系。‌

A: 缩排位置相同的if
B: 在其之前未配对的if
C: 其之前未配对的最近的if 
D: 同一行上的if
答案:  其之前未配对的最近的if 

4、单选题:
 与表达式if(!k)等价的是(     )。‎

A: if(k==0)
B: if(k!=1)   
C: if(-k)
D: if(k!=0)
答案:   if(k==0)

5、单选题:
以下代码执行后,a、b、c的值分别为(    )。‌int a=8,b=10,c=3;‌if (a>b) ‌    c=a,a=b,b=c;‌

A: 10 3 3 
B: 8 10 3
C: 10 8 8
D: 10 10 8
答案:  8 10 3

6、单选题:
下列描述正确的是(   ) 。‌

A: 表示m>n为true或m<n为true的表达式为m>n&&m<n
B: switch语句结构中必须有default语句
C: if语句结构中必须有else语句
D: 如果至少有一个操作数为true,则包含”||”运算符的表达式为true
答案:  如果至少有一个操作数为true,则包含”||”运算符的表达式为true

7、单选题:
下面程序的运行结果是(   ).‌#include<iostream>‌using namespace std;‌void main(void)‌{  int i=10; ‌switch (i)‌{   case  9:i++;‌    case  10:++i;‌    case  11:i++;‌    default:i=i+1;‌}‌cout<<i<<endl;‌}‌

A: 9
B: 10
C: 11
D: 13
答案:  13

8、单选题:
若int a=6,则执行完下列语句后,a的值为(   ).‏if (a>10)‏  a-=5;‏  a+=5;‏

A: 1
B: 6
C: 10
D: 11
答案:  11

9、单选题:
#include<iostream>‎using namespace std;‎int main()‎{‎int a=3;‎if(a=5)‎cout<<a+1<<endl;‎else‎cout<<a<<endl;‎return 0;‎}‎程序的输出是(   )。‎

A: 3
B: 4
C: 5
D: 6
答案:  6

10、单选题:
‍若x和y是程序中的两个整型变量,则下列if语句中正确的是(   )。‍

A: if(x==0) y=1; else y=2;
B: if(x==0) then y=1 else y=2;
C: if(x==0) y=1 else y=2;
D: if x==0 y=1; else y=2;
答案:  if(x==0) y=1; else y=2;

第4章——循环结构周而复始,求同存异

第四章单元测试

1、单选题:
下面关于break语句的描述中,不正确的是(   ).‎‏‎

A: break可以用于循环体内 
B: break语句可以在for循环语句中出现多次
C: break语句可以在switch语句中出现多次
D: 一个break语句就可以跳出多重循环
答案:  一个break语句就可以跳出多重循环

2、单选题:
以下语句不正确的是(     )。‍

A: 语句for(i=0;;)表示无限循环
B: for(;;)表示无限循环
C: for(   )也表示无限循环
D: while(1)表示无限循环
答案:  for(   )也表示无限循环

3、单选题:
有如下程序:  ‌#include<iostream>  ‌using namespace std; ‌int main(   )‌{ int  i ,f,f1=0,f2=1;  ‌for( i=3;i<=6;i++)‌{  f=f1+f2; ‌ f1=f2;‌f2=f;  } ‌cout<<f<<endl; ‌return 0; }  运行时的输出结果是(   )‌

A: 2
B: 3
C: 5
D: 8
答案:  5

4、单选题:
有如下程序段:‎int i=5;‎while (int i=0){ cout<<‘*’; i–; }‎运行时输出”*”的个数是(   )。‎

A: 0
B: 1
C: 5
D: 无穷
答案:  0

5、单选题:
执行完以下语句‍int i=0; do i++; while(i*i<10);‍时,do后面的循环体语句i++被执行的次数为 (    )‍

A: 2
B: 3
C: 4
D: 5
答案:  4

6、单选题:
有如下循环语句:for(int i=50; i>20; i-=2)  cout<<i<<‘,’;‏​运行时循环体的执行次数是(    )‏

A: 14
B: 15
C: 30
D: 27
答案:  15

7、单选题:
‌有如下程序段:  int i=1;  while (1) {      i++;      if(i == 10) break;      if(i%2 == 0) cout << ‘*’;  }  执行这个程序段输出字符*的个数是(   )‍‌‍

A: 10
B: 3
C: 4
D: 5
答案:  4

8、单选题:
有如下程序:‎#include<iostream> ‎using namespace std;‎int main(  ){‎int sum;‎for(int i=0; i<6; i+=3){‎sum=i; ‎for(int j = i; j<6; j++)   sum+=j;‎} ‎cout<<sum<<end1; ‎return 0;‎}‎运行时的输出结果是(   )。‎

A: 3
B: 10
C: 12
D: 15
答案:  15

9、单选题:
下面程序的运行结果是(  )。‍#include<iostream>‍using namespace std;‍void main()‍{  int i,j,a=0;‍   for(i=0;i<2;i++)‍   { ‍      for (j=0; j<4; j++)‍       {  if (j%2)  break;‍          a++;‍        }‍       a++;‍    }‍    cout<<a<<endl;‍}‍

A: 3
B: 4
C: 5
D: 6
答案:  4

10、单选题:
有如下程序段:‏for (int i=1;i<=50;i++){‏   if (i%3!=0)‏   continue;‏else‏   if(i%5!=0)‏   continue;‏   cout<<i<<“,”;‏}‏‌执行这个程序段的输出是(     )‏

A: 15,30,45,
B: 15,45,
C: 15,30,
D: 30,45,
答案:  15,30,45,

第5章——数组实现算法的利器

第五章单元测试

1、单选题:
要定义整型数组x,使之包括初值为0的三个元素,下列语句中错误的是(  )‍‎‍

A: int x[3]={0,0,0};  
B: int x[ ]={0};
C: int x[3]={0};
D: int x[ ]={0,0,0};
答案:  int x[ ]={0};

2、单选题:
在C++语言中,二维数组元素在内存中的存放顺序是(   )。‌‎‌

A: 按行存放    
B: 按列存放 
C: 由用户自己定义
D: 由编译器决定
答案:  按行存放    

3、单选题:
在下述对C++语言字符数组的描述中,有错误的是(   )。‍‍‍

A: 字符数组可以存放字符串。
B: 字符数组中的字符串可以进行整体输入输出。
C: 可以在赋值语句中通过赋值运算符”=”对字符数组整体赋值。
D: 字符数组的下标从0开始。
答案:  可以在赋值语句中通过赋值运算符”=”对字符数组整体赋值。

4、单选题:
以下数组的初始化,正确的是(    )。​‏​

A: int a[]={1,2,3,4,5};
B: int a[4]={1,2,3,4,5};
C: int a[2]={1,2,3} ;
D: int a[][]={1,2,3,4};
答案:  int a[]={1,2,3,4,5};

5、单选题:
下面关于数组的描述错误的是(   )。‎‍‎

A: 在C++语言中数组的名字就是该数组第一个元素的首地址。 
B: 长度为n的数组,下标的范围是0~n-1 。
C: 数组的大小必须在编译时确定。
D: 数组元素的个数在定义时可以缺省。
答案:  数组元素的个数在定义时可以缺省。

6、单选题:
下面程序的运行结果是(   )。‌char c[5] = {‘a’,’b’,’  ‘,’c’, ‘  ‘};‌cout<<c;‌‌‌

A: 1012ACF1H
B: ab
C: ab c
D: 以上都不是
答案:  以上都不是

7、单选题:
有如下程序段:‍char c[20]=”examination”;‍c[4]=0;‍cout<<c<<endl;‍执行这个程序段的输出是(     )。‍‎‍

A: examination 
B: exam
C: exa
D: exami
答案:  exam

8、单选题:
以下程序运行后的输出结果是(    )。‏int main( )‏  { char a[]=”abbcabbcabbc”;‏   int i =0,j=0,k=0;‏   while(a[i])‏   { if(a[i] ==’a’)‏    j++;‏    if(a[i]==’b’)‏    k++;‏    i++;‏  }    ‏ cout<<j<<” “<<k<<endl;‏return 0;‏}‏‎‏

A: 2   6
B: 3    5
C: 4    7
D: 3    6
答案:  3    6

9、单选题:
已知:‍int i,x[3][3] = {1,2,3,4,5,6,7,8,9};‍则下面语句的输出结果是(   ).‍for(i = 0;i < 3;i ++)‍   cout<<x[i][2-i]<<” “;‍‎‍

A: 1  5  9
B: 1   4   7
C: 3    5    7
D: 3    6    9
答案:  3    5    7

10、单选题:
下面程序的运行结果是(   ).​#include <iostream>​#include <cstring>​using namespace std;​int main( )​{​ char s1[10]=”abc”;​ char s2[20]=”inter”;​ int k=0,j=0;​ while (s2[k]) k++;​ while(s1[j])​    s2[k–]=s1[j++];​ cout<<s2<<endl;​return 0;​}​

A: inter
B: abc
C: interabc
D: intcba
答案:  intcba

第6章——指针所向披靡的“金箍棒” 魂

第6章单元测试

1、单选题:
下面程序的运行结果是(   ).​#include<iostream>​using namespace std;​int  main (  )​{  float  a=1,b=2,c;​   float  *p1=&a,*p2;​   p2=&b;​   c= * p1 + *p2;​   cout<<*p1<<‘n’;​}​‎​

A: 1
B: 2
C: a
D: b
答案:  1

2、单选题:
设有定义一维数组如下:int a[5],*p=a;,则下列描述中错误的是(   ).‏

A: 表达式 p=p+1是合法的
B: 表达式a=a+1是合法的
C: 表达式p-a是合法的
D: 表达式a+2是合法的
答案:  表达式a=a+1是合法的

3、单选题:
已知数组arr的定义如下:  int arr[5] = {1,2,3,4,5};  下列语句中输出结果不是2的是(  )‌

A: cout << *arr+1 <<endl;
B: cout << *(arr+1)<<endl;
C: cout << arr[1] <<endl;
D: cout << *arr <<endl;
答案:  cout << *arr <<endl;

4、单选题:
 下列语句中,正确的是(   )。‎

A: char*myString=”Hello-World!”;
B: char myString=”Hello-World!”;
C: char myString[11]=”Hello-World!”;
D: char myString[12]=”Hello-World!”;
答案:  char*myString=”Hello-World!”;

5、单选题:
已知:int m=10;在下列语句中错误的是(    )‏

A: int *p=new int(m);  
B: int *p=new int[m]={0};
C: float *p=new float(m);         
D: float *p=new float[m];
答案:  int *p=new int[m]={0};

6、单选题:
下面程序的运行结果是(   ).‎#include<iostream>‎using namespace std;‎void main(void)‎{‎  int a[5]={10,20,30,40,50};‎  int *p=&a[0];‎  p++;‎  cout<<++*p<<endl;‎}‎‏‎

A: 10
B: 21
C: 31
D: 41
答案:  21

7、单选题:
‌下列程序的输出结果是​#include <iostream>​using namespace std;​int main()​{​     char a[] = “Hello, World”;​     char *ptr = a;​     while (*ptr)​     {​           if (*ptr >= ‘a’ && *ptr <= ‘z’)​                 cout << char(*ptr + ‘A’ -‘a’);​           else cout << *ptr;​           ptr++;​     }​     return 0;​}​

A:  HELLO, WORLD      
B: Hello, World
C: hELLO, wORLD   
D: hello, world
答案:   HELLO, WORLD      

8、单选题:
已知有数组定义 char a[3][4]; ‌下列表达式中错误的是(     )。 ‌

A: a[2]=”WIN” ;
B: strcpy(a[2],”WIN”) ;
C: a[2][3]=’W’ ;
D: a[0][1]=a[0][1] ;
答案:  a[2]=”WIN” ;

9、单选题:
‏下列程序运行时的输出结果是(  )。‎‏#include <iostream>‎using namespace std;‎‏int main()‎‏ {int a[7]={23,15,64,33,40,58};‎‏int s1,s2,*p;‎‏s1=s2=a[0];‎‏for(p=a+1;*p;p++)‎‏{if(s1>*p) s1=*p;‎‏if(s2<*p) s2=*p;}‎‏cout<<s2;‎‏return 0;‎‏} ‎‏‎

A: 23
B: 58
C: 64
D: 79
答案:  64

10、单选题:
‌下面程序的运行结果是(   ).‍‌#include<iostream>using namespace std;int main( ){int aa[3][3]={{1},{2},{3}},i,*p=&aa[0][0];for(i=0;i<2;i++) {if(i==0) aa[i][i+1]=*p+1; else ++p; cout<<*p<<”   “;}cout<<endl;return 0;}‍

A: 1   1
B: 2      1
C: 1     2
D: 3    1
答案:  1     2

第六章 练一练 经典基础题

1、单选题:
阅读程序,请输出程序的结果。‏#include<iostream>‏using namespace std;‏int main()‏{ int a[]={11,16,13,14,15};‏  int *ptr = a;‏  cout<<*ptr<<endl;‏  cout<<*(++ptr)<<endl;‏ return 0; ‏}‏

A: 1111
B: 1116
C: 1112
D: 1617
答案:  1116

2、单选题:
​阅读程序,请输出程序的结果。‏​#include<iostream>‏​using namespace std;‏​int main()‏​{ int a[]={11,16,13,14,15};‏​  int *ptr = a;‏​  cout<<*ptr<<endl;‏​  cout<<*(ptr++)<<endl;‏​ return 0; ‏​}‏

A: 1111
B: 1116
C: 1112
D: 1616
答案:  1111

3、单选题:
‌阅读程序,输出结果。​‌#include<iostream>​‌using namespace std;​‌int main()​‌{ int a[]={11,16,13,14,15};​‌  int *ptr = a;​‌  cout<<*ptr<<endl;​‌  cout<<*ptr++<<endl;​‌  cout<<a[0]<<endl;​‌  cout<<*ptr<<endl;​‌ return 0; ​‌}​‌​

A: 11111116
B: 11111211
C: 11121112
D: 11161117
答案:  11111116

4、单选题:
‎#include<iostream>‎‎using namespace std;‎‎int main()‎‎{ int a[]={11,16,13,14,15};‎‎  int *ptr = a;‎‎  cout<<*ptr<<endl;‎‎  cout<<(*ptr)++<<endl;‎‎  cout<<a[0]<<endl;‎‎  cout<<*ptr<<endl;‎‎ return 0; ‎‎}‎‎‎

A: 11111116
B: 11111212
C: 11121116
D: 11161117
答案:  11111212

5、单选题:
​阅读程序,输出结果。‌​#include<iostream>‌​using namespace std;‌​int main()‌​{ int a[]={11,16,13,14,15};‌​  int *ptr = a;‌​  cout<<*ptr<<endl;‌​  cout<<*(ptr++)<<endl;‌​  cout<<a[0]<<endl;‌​  cout<<*ptr<<endl;‌​ return 0; ‌​}‌

A: 11111116
B: 11121112
C: 11161116
D: 11161117
答案:  11111116

6、单选题:
‌阅读程序,输出结果。‍‌#include<iostream>‍‌using namespace std;‍‌int main()‍‌{ int a[]={11,16,13,14,15};‍‌  int *ptr = a;‍‌  cout<<*ptr<<endl;‍‌  cout<<*++ptr<<endl;‍‌  cout<<a[0]<<endl;‍‌  cout<<*ptr<<endl;‍‌ return 0; ‍‌}‍‌‍

A: 11111116
B: 11161116
C: 11111112
D: 11111212
答案:  11161116

7、单选题:
‌阅读程序,输出结果。​‌#include<iostream>​‌using namespace std;​‌int main()​‌{ int a[]={11,16,13,14,15};​‌  int *ptr = a;​‌  cout<<*ptr<<endl;​‌  cout<<++*ptr<<endl;​‌  cout<<a[0]<<endl;​‌  cout<<*ptr<<endl;​‌ return 0; ​‌}​

A: 11111112
B: 11161116
C: 11121212
D: 11121112
答案:  11121212

8、单选题:
​阅读程序,输出结果。‌​#include<iostream>‌​using namespace std;‌​int main()‌​{ int a[]={11,16,13,14,15};‌​  int *ptr = a;‌​  cout<<*ptr<<endl;‌​  cout<<*(++ptr)<<endl;‌​  cout<<a[0]<<endl;‌​  cout<<*ptr<<endl;‌​ return 0; ‌​}‌

A: 11111112
B: 11161116
C: 11121112
D: 11111116
答案:  11161116

9、单选题:
​阅读程序,输出结果‎​#include<iostream>‎​using namespace std;‎​int main()‎​{ int a[]={11,16,13,14,15};‎​  int *ptr = a;‎​  cout<<*ptr<<”  “<<*(++ptr)<<endl;‎​ return 0; ‎​}‎

A: 16   16
B: 11  11
C: 11  16
D: 11  12
答案:  16   16

10、单选题:
‏以下程序的功能是:将无符号八进制数字构成的字符串转换为十进制整数。例如,输入的字符串为:556,则输出十进制整数366。请在黄色处选择合适的语句。‏#include<iostream>‏using namespace std;‏int main()‏{char *p,s[6];‏ int n; ‏  p=s;‏  cin>>p;‏  n=*p-‘0’;‏  while(    !=”)‏     n=n*8+*p-‘0’;‏  cout<<n<<endl;‏  return 0;‏}‏‏‏

A: *++p
B: *p++  
C: (*p)++
D: *p
答案:  *++p

第六章 练一练 经典提高题

1、单选题:
‌阅读程序,回答‏#include <iostream>‏#include<iomanip>‏using namespace std;‏int main()‏{ int a[3][4]={1,2,3,4,5,6,7,8,9,10,11,12};‏int (*p)[4]; //该语句是定义一个数组指针,指向含4个元素的一维数组。‏ p=a;       ‏ cout<<*p<<endl;‏ p++;       ‏ cout<<*p<<endl;‏  return 0;‏}‏‌请问这两个输出的地址差是多少?‏

A: 16
B: 4
C: 1
D: 编译错误
答案:  16

2、单选题:
‍阅读程序,回答下面‌‍#include <iostream>‌‍#include<iomanip>‌‍using namespace std;‌‍int main()‌‍{ int a[3][4]={1,2,3,4,5,6,7,8,9,10,11,12};‌‍int *p[3]; //定义一个指针数组,表示一个一维数组内存放着三个指针变量,分别是p[0]、p[1]、p[2]‌‍ p=a;       ‌‍ cout<<*p<<endl;‌‍ p++;       ‌‍ cout<<*p<<endl;‌‍  return 0;‌‍}‌请问这两个输出的数据相差多少?‌

A: 16
B: 4
C: 1
D: 编译错误
答案:  编译错误

3、单选题:
若定义 ‍char s[2][3]={“ab”, “cd”}, *p=(char *)s;‍//字符型指针p存放的是字符串s的首地址,而字符串s表示的是这样一个字符串:‍‍那么下列表达式语法正确,并且其值与 s[1][1]相等的表达式(并非一定与其等价)是() ‍//根据字符串的表示,s[1][1]是字符‘d’‍

A: *(s+3)
B: p[1][1]   
C: *(p+3)
D: char(*++p+2)
答案:  char(*++p+2)

4、单选题:
#include<iostream>‍using namespace std;‍int main()‍{‍    int a[5] = { 1, 2, 3, 4, 5 };‍    int *ptr = (int*)(&a + 1);‍    cout<< *(a + 1)<<”  “<< *(ptr – 1)<<endl;‍    return 0;‍}‍程序运行结果是什么?‍

A: 2   5
B: 编译错误
C: 1   2
D: 2   不确定
答案:  2   5

5、单选题:
阅读程序,输出结果。‏#include<iostream>‏using namespace std;‏int main()‏{‏    int a[3][2] = { 1, 2,4, 5 };‏    int *p;‏    p = a[0];‏   cout<<p[0]<<”  “<<p[1]<<”  “<<p[2]<<”  “<<p[3]<<endl;‏    p=a[1];‏   cout<<p[0]<<”  “<<p[1]<<”  “<<p[2]<<”  “<<p[3]<<endl;‏     p=a[2];‏   cout<<p[0]<<”  “<<p[1]<<”  “<<p[2]<<”  “<<p[3]<<endl;‏    return 0;‏}‏‎‏

A: 1  2  4  5 4  5  0  00  0 不确定  不确定
B: 编译错误
C: 1  2  4  5 0  0  0  00  0 不确定  不确定
D: 1  2  4  5 4  5  0  0不确定 不确定 不确定  不确定
答案:  1  2  4  5 4  5  0  00  0 不确定  不确定

6、单选题:
‏阅读程序,输出结果。‏#include<iostream>‏using namespace std;‏int main()‏{‏    int aa[2][5] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };‏    int *ptr1 = (int *)(&aa + 1);‏    int *ptr2 = (int *)(*(aa + 1));‏    cout<<*(ptr1 – 1)<<”  “<< *(ptr2 – 1);‏    return 0;‏}‏

A: 10    5
B: 编译错误
C: 地址    5
D: 10   地址
答案:  10    5

7、单选题:
‎阅读程序,输出结果‎#include<iostream>‎using namespace std;‎int main()‎{‎    char *a[] = { “work”, “at”, “alibaba” };‎    char **pa = a;‎    pa++;‎    cout<<*pa<<endl;‎    return 0;‎}‎

A: at
B: 编译错误
C: work
D: alibaba
答案:  at

8、单选题:
有定义语句:char s[3][10],(*k)[3],*p;则对于下列赋值语句,哪个是正确的?

A:  p = s[0];
B: p = s;
C:  p = k;
D: k = s;
答案:   p = s[0];

9、单选题:
如定义 int a[3][4];‎下面哪个不能表示 a[1][1]?‎​‎

A: *(&a[0][0]+5)
B: *(*(a+1)+1)
C: *(&a[1]+1)
D:  *(a[1]+1)
答案:  *(&a[1]+1)

10、单选题:
阅读程序,输出结果‍#include<iostream>‍using namespace std;‍ int main()‍{   int a[3][4]={{0,1,2,10},{3,4,5,11},{6,7,8,12}};‍     cout<<*(&a[0][0])<<endl;‍     cout<<**a<<endl;‍     cout<<*(&a[1][0])<<endl;‍     cout<<*(a[0]+1)<<endl;‍     cout<<*(a+1)<<endl;‍    return 0;‍ }‍

A: 0031第一行的首地址
B: 第一个元素地址0313
C: 00313
D: 003131
答案:  0031第一行的首地址

第7章 函数面向过程的基础

第7章单元测试

1、单选题:
有如下程序段:‏int i=4;int j=1;‏int main( ) {‏int i=8,j=i;‏cout<<i<<j<<endl;‏}‏‎运行时的输出结果是______。‏

A: 44
B: 41
C: 88
D: 81
答案:  88

2、单选题:
有以下程序‏#include<iostream>‏int i = 0 ; ‏void   fun()‏{   {‏        static int i = 1;‏        cout<<i++<<‘,’;‏}‏cout<<::i<<‘,’;‏}‏int main()‏{‏   fun();  fun();‏   return 0;‏}‏程序执行后的输出结果是(   )‏

A: 0,1,1,2,
B: 1,2,2,3,
C: 2,0,3,0,
D: 1,0,2,0,
答案:  1,0,2,0,

3、单选题:
已知函数fun的原型为‌int fun (int,int,int);‌下列重载函数原型中错误的是______。‌

A: char fun(int,int);
B: double fun(int,int,double);
C: int fun(int,clar*);
D: float fun(int,int,int);
答案:  float fun(int,int,int);

4、单选题:
下列函数原型声明中错误的是(   )‎

A: void Fun(int x=0, int y=0);  
B: void Fun(int x, int y);
C: void Fun(int x, int y=0); 
D: void Fun(int x=0, int y);
答案:  void Fun(int x=0, int y);

5、单选题:
‏已知函数FA调用FB,若要把这两个函数定义在同一个文件中,则‏

A: FA必须定义在FB之前
B: FB必须定义在FA之前
C: 若FA定义在FB之后,则FA的原型必须出现在FB的定义之前
D: 若FB定义在FA之后,则FB的原型必须出现在FA的定义之前
答案:  若FB定义在FA之后,则FB的原型必须出现在FA的定义之前

6、单选题:
为了提高函数调用的实际运行速度,可以将较简单的函数定义为  ‎

A: 内联函数
B: 重载函数 
C: 递归函数
D: 函数模板
答案:  内联函数

7、单选题:
 下面的函数利用递归实现了求1+2+3…..+n的功能:​int sum(int n){​    if( n==0 )​        return 0;​    else​        return n+sum(n-1);​}​在执行sum(10)的过程中,递归调用sum函数的次数是(   )。​

A: 9
B: 10
C: 11
D: 8
答案:  10

8、单选题:
已知函数f的原型是:void f(int *a, long &b); 变量v1、v2的定义是:‌i



上方为免费预览版答案,如需购买完整答案,请点击下方红字:



点击这里,购买完整版答案


为了方便下次阅读,建议在浏览器添加书签收藏本网页

添加书签方法:

1.电脑按键盘的Ctrl键+D键即可收藏本网页

2.手机浏览器可以添加书签收藏本网页

点击浏览器底部菜单-【添加书签】-收藏本网页

面向对象程序设计基础(内蒙古工业大学)1454215178 中国大学MOOC答案100分完整版第1张

点击浏览器底部菜单-【书签/历史】-可查看本网页

面向对象程序设计基础(内蒙古工业大学)1454215178 中国大学MOOC答案100分完整版第2张


获取更多慕课答案,欢迎在浏览器访问我们的网站:



http://mooc.mengmianren.com

面向对象程序设计基础(内蒙古工业大学)1454215178 中国大学MOOC答案100分完整版第3张

面向对象程序设计基础(内蒙古工业大学)1454215178 中国大学MOOC答案100分完整版第4张

注:请切换至英文输入法输入域名,如果没有成功进入网站,请输入完整域名:http://mooc.mengmianren.com/


我们的公众号

打开手机微信,扫一扫下方二维码,关注微信公众号:萌面人APP

本公众号可查看各种网课答案,还可免费查看大学教材答案

点击这里,可查看公众号功能介绍

面向对象程序设计基础(内蒙古工业大学)1454215178 中国大学MOOC答案100分完整版第5张




APP下载



点击这里下载萌面人APP,使用更方便!




APP功能说明

1.可查看各种网课答案

点击【萌面人官网】,可查看知到智慧树,超星尔雅学习通,学堂在线等网课答案

面向对象程序设计基础(内蒙古工业大学)1454215178 中国大学MOOC答案100分完整版第6张

点击【中国大学慕课答案】,可查看mooc慕课答案

面向对象程序设计基础(内蒙古工业大学)1454215178 中国大学MOOC答案100分完整版第7张

2.可一键领取淘宝/天猫/京东/拼多多无门槛优惠券

如图所示,点击对应图标即可领取淘宝/天猫/京东/拼多多无门槛优惠券

面向对象程序设计基础(内蒙古工业大学)1454215178 中国大学MOOC答案100分完整版第8张


邢搔钩嫂讥坟好聘闯能藉讥纤