中国大学MOOC答案下面关于break语句的描述中,不正确的是( ). A、break可以用于循环体内 B、break语句可以在for循环语句中出现多次 C、break语句可以在switch语句中出现多次 D、一个break语句就可以跳出多重循环 喵查答案:一个break语句就可以跳出多重循环 ……继续阅读 »
中国大学MOOC答案以下语句不正确的是( )。 A、语句for(i=0;;)表示无限循环 B、for(;;)表示无限循环 C、for( )也表示无限循环 D、while(1)表示无限循环 喵查答案:for( )也表示无限循环 ……继续阅读 »
中国大学MOOC答案有如下程序: #include 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 ……继续阅读 »
中国大学MOOC答案有如下程序段:int i=5;while (int i=0){ cout<<'*'; i–; }运行时输出”*”的个数是( )。 A、0 B、1 C、5 D、无穷 喵查答案:0 ……继续阅读 »
中国大学MOOC答案执行完以下语句int i=0; do i++; while(i*i<10);时,do后面的循环体语句i++被执行的次数为 ( ) A、2 B、3 C、4 D、5 喵查答案:4 ……继续阅读 »
中国大学MOOC答案有如下循环语句:for(int i=50; i>20; i-=2) cout<<i<<',';运行时循环体的执行次数是( ) A、14 B、15 C、30 D、27 喵查答案:15 ……继续阅读 »
中国大学MOOC答案有如下程序段: int i=1; while (1) { i++; if(i == 10) break; if(i%2 == 0) cout << '*'; } 执行这个程序段输出字符*的个数是( ) A、10 B、3 C、4 D、5 喵查答案:4 ……继续阅读 »
中国大学MOOC答案 已知下列语句中的x和y都是int型变量,其中错误的语句( )。 A、x=y++; B、x=++y; C、(x+y)++; D、 ++x==y; 喵查答案:(x+y)++; ……继续阅读 »
中国大学MOOC答案有如下程序:#include 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 ……继续阅读 »
中国大学MOOC答案下面程序的运行结果是( )。#includeusing 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 ……继续阅读 »
中国大学MOOC答案有如下程序段: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, ……继续阅读 »
中国大学MOOC答案执行语句序列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、23 D、12 喵查答案:12 ……继续阅读 »
中国大学MOOC答案下面程序的输出结果是( ).#includeusing 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 ……继续阅读 »
中国大学MOOC答案为了避免嵌套的if-else语句的二义性,C++语言规定else总是与( )组成配对关系。 A、缩排位置相同的if B、在其之前未配对的if C、其之前未配对的最近的if D、同一行上的if 喵查答案:其之前未配对的最近的if ……继续阅读 »