#G052. GESP level2 循环结构
GESP level2 循环结构
GESP level2 - 循环结构
- 下面C++代码执行后的输出是?
{{ select(1) }}int n,a,m,i; n=3, a = 5; m = (a - 1) * 2; for (i=0; i<n-1; i++) m = (m - 1) * 2; cout << m;
- 8
- 14
- 26
- 50
- 下面C++代码执行后的输出是?
{{ select(2) }}int n,i,result; n = 81; i = 1, result = 1; while (i * i <= n){ if (n % (i * i) == 0) result = i * i; i += 1; } cout << result;
- 16
- 36
- 49
- 81
- 下面C++代码执行后的输出是?
{{ select(3) }}int s,t,ans; s = 2, t = 10; ans = 0; while (s != t){ if (t % 2 == 0 && t / 2 >= s) t /= 2; else t -= 1; ans += 1; } cout << ans;
- 2
- 3
- 4
- 5
- 在C++中,与 for(int i=0; i<10; i++) 效果相同的是? {{ select(4) }}
- for(int i=0; i<10; i+=1)
- for(int i=1; i<=10; i++)
- for(int i=10; i>0; i--)
- for(int i=10; i<1; i++)
- 在C++中,与 for(int i = 10; i < 20; i +=2) cout << i; 输出结果相同的是? {{ select(5) }}
- for(int i = 10; i < 19; i +=2) cout << i;
- for(int i = 11; i < 19; i +=2) cout << i;
- for(int i = 10; i < 21; i +=2) cout << i;
- 以上均不对