2、做题中请勿使用F功能键或查看源代码,如使用系统会记录下来
3、诚信考试,请勿上网搜索答案,与其他考生交流,求助外援等
4、做题中途遇到问题被退出,在有效期内仍可进入再次进行答题
阅读程序,填写结果
1 #include<iostream>
2 using namespace std;
3 int main(){
4 int u[4], a, b, c, x, y, z;
5 for(int i = 0; i < 4; ++i)
6 cin >> u[i];
7 a = u[0] + u[1] + u[2] + u[3] - 5;
8 b = u[0] * (u[1] - u[2] / u[3] + 8);
9 c = u[0] * u[1] / u[2] * u[3];
10 x = (a + b + 2) * 3 - u[(c + 3) % 4];
11 y = (c * 100 - 13) / a / (u[b % 3] * 5);
12 if((x+y) % 2 == 0)
13 z = (a + b + c + x + y) / 2;
14 z = (a + b + c - x - y) * 2;
15 cout << x + y - z;
16 return 0;
17 }
程序输入: 2 5 7 4
请填写输出结果
阅读程序,填写结果:
1 #include<iostream>
2 #include<cstring>
3 using namespace std;
4
5 int n, jr, jw, jt;
6 char ch1, ch[21];
7
8 int main(){
9 cin >> n;
10 for(int i = 1; i <= n; ++i){
11 cin >> ch[i];
12 }
13 jr = 1; jw = n; jt = n;
14 while (jr <= jw) {
15 if (ch[jw] == 'R'){
16 ch1 = ch[jr]; ch[jr] = ch[jw]; ch[jw] = ch1;
17 jr = jr + 1;
18 } else if (ch[jw] == 'W') {
19 jw = jw - 1;
20 } else {
21 ch1 = ch[jw]; ch[jw] = ch[jt]; ch[jt] = ch1;
22 jw = jw - 1;
23 jt = jt - 1;
24 }
25 }
26 for(int i = 1; i <= n; ++i){
27 cout << ch[i];
28 }
29 cout << endl;
30 return 0;
31 }
输入:
10
RTRTWWRTTR
请填写输出:
阅读程序,填写结果
1 #include<iostream>
2 #include<cmath>
3 using namespace std;
4
5 int n, i, sum;
6 int a[51];
7
8 void work(int p, int r){
9 int i, j;
10 if (p < r){
11 i = p - 1;
12 for(j = p; j < r; ++j)
13 if (a[j] >= a[r]) {
14 i++;
15 swap(a[i], a[j]); // swap是交换函数
16 }
17 swap(a[i+1], a[r]);
18 work(p, i);
19 work(i+2, r);
20 }
21 }
22
23 int main(){
24 cin >> n;
25 for(i = 1; i <= n; ++i)
26 cin >> a[i];
27 work(1, n);
28 for(i = 1; i <= n-1; ++i)
29 sum += abs(a[i+1] - a[i]);
30 cout << sum;
31 return 0;
32 }
程序输入:10 23 435 12 345 3123 43 456 12 32 -100
请填写程序输出:
阅读程序,填写结果
1 #include<iostream>
2 using namespace std;
3
4 int i, j, s, sp1;
5 bool p;
6 int a[11];
7
8 int main(){
9 sp1 = 1; a[1] = 2; j = 2;
10 while (sp1 < 10) {
11 j += 1; p = true;
12 for (i = 2; i < j; ++i)
13 if (j % i == 0) p = false;
14 if (p) a[++sp1] = j;
15 }
16 j = 2; p = true;
17 while (p) {
18 s = 1;
19 for(i = 1; i <= j; ++i)
20 s *= a[i];
21 s++;
22 for(i = 2; i < s; ++i)
23 if(s % i == 0) p = false;
24 j++;
25 }
26 cout << s;
27 return 0;
28 }
这个程序没有输入,请直接填写结果
6题 | 被引用0次