举一反三
- 中国大学MOOC: 下面程序执行后的输出结果是( )。#include int main(){ int i=0,s=0; for (;;) { if(i==3||i==5) continue; if (i==6) break; i++; s+=i; }; printf(%d,s); return 0;}#include int main(){ int i=0,s=0; for (;;) { if(i==3||i==5) continue; if (i==6) break; i++; s+=i; }; printf(%d,s); return 0;}#include int main(){ int i=0,s=0; for (;;) { if(i==3||i==5) continue; if (i==6) break; i++; s+=i; }; printf(%d,s); return 0;}#include int main(){ int i=0,s=0; for (;;) { if(i==3||i==5) continue;
- 【单选题】下面程序执行后的输出结果是()。#include <stdio.h>int main(){int i=0,s=0;for (;;) {if(i==3||i==5) continue;if (i==6) break;i++; s+=i;};printf("%d",s); return 0;}#include <stdio.h>int main(){int i=0,s=0;for (;;) {if(i==3||i==5) continue;if (i==6) break;i++; s+=i;};printf("%d",s); return 0;}#include <stdio.h>int main(){int i=0,s=0;for (;;) {if(i==3||i==5) continue;if (i==6) break;i++; s+=i;};printf("%d",s); return 0;}#include <stdio.h>int main(){int i=0,s=0; A. 10 B. 13 C. 21 D. 死循环
- 下面程序的运行结果为:int i=1,s=3;do{ s+=i++;if(s%7==0) continue;else ++i;}while(s<;15);printf(“%d”,i);
- 下面程序运行的结果为int i,j,s=0;for(i=1,j=5;i<;j;i++,j--){s+=i*10+j;}System.out.println(s);
- int f() { static int i=0; int s=1; s+=i; i++; return s; } main() { int i,a=0; for(i=0;i<5;i++) a+=f(); printf(“%d ”, a); }输出结果为
内容
- 0
下面程序执行后的输出结果是()。#includeintmain(){inti=0,s=0;for(;;){if(i==3||i==5)continue;if(i==6)break;i++;s+=i;};printf("%d",s);return0;}#includeintmain(){inti=0,s=0;for(;;){if(i==3||i==5)continue;if(i==6)break;i++;s+=i;};printf("%d",s);return0;}#includeintmain(){inti=0,s=0;for(;;){if(i==3||i==5)continue;if(i==6)break;i++;s+=i;};printf("%d",s);return0;}#includeintmain(){inti=0,s=0;for(;;){if(i==3||i==5)continue;if(i==6)break;i++;s+=i;};printf("%d",s);return0;} A: 10 B: 13 C: 21 D: 死循环
- 1
以下程序的运行结果是 inti = 0, s = 0; for( ; ; ) { if(i == 3 || i == 5) continue; if(i == 6) break; i++;s += i; } printf("%d",s);
- 2
下面代码段的执行结果是 int i, s = 0 ; int a[ ] = { 10 , 20 , 30 , 40 , 50 , 60 , 70 , 80 , 90 }; for ( i = 0 ; i < a.length ; i ++ ) if ( a[i]%3 = = 0 ) s += a[i] ; System.out.println("s="+s);
- 3
下面程序段的运行结果是_____。#includeiostreamusing namespace std;int main(){ int i=1,s=3; do {s+=i++; if (s%7==0) continue; else ++i;} while(s15); couti;}
- 4
有以下程序: int main() { int i,s=1; for(i=1 ;i<=50 ;i++) if( !(i%5)&& !(i%3)) s+=i; printf(“%d\n”,s); return 0; } 程序的输出结果是( )