C. 阅读程序题-0000
阅读程序题-0000
该比赛已结束,您无法在比赛模式下递交该题目。您可以点击“在题库中打开”以普通模式查看和递交本题。
#include <bits/stdc++.h>
using namespace std;
int a[1000010];
int main() {
int n;
cin >> n;
for (int i = 1; i <= n; i++) {
cin >> a[i];
}
int maxCnt = 1;
int cnt = 1;
for (int i = 2; i <= n; i++) {
if (a[i] > a[i - 1]) {
cnt++;
}
else {
// (1)
cnt = 1;
}
maxCnt = max(maxCnt, cnt);
}
cout << maxCnt;
return 0;
}
判断题
- 若输入
6 1 2 1 2 2 4,则输出 4 {{ select(1) }}
- 对
- 错
- 程序的功能为:求最大连续上升段的长度 {{ select(2) }}
- 对
- 错
- 把
maxCnt = max(maxCnt, cnt);改到 (1) 位置程序也是正确的 {{ select(3) }}
- 对
- 错
选择题
- 若输入
5 1 2 2 3 4,则输出 {{ select(4) }}
- 2
- 3
- 4
- 5
- 若把程序中的部分语句修改,仍能实现相同效果的是 {{ select(5) }}
- 把
i = 2改为i = 1 - 把
a[i] > a[i - 1]改为a[i] < a[i + 1] - 把
int maxCnt = 1;改为int maxCnt = 0; - 把
for (int i = 2; i <= n; i++)改为for (int i = n; i > 1; i--)
- 上述程序不可以解决
n为多大的问题 {{ select(6) }}
答案:
BAB
BDA