#CS41007. 阅读程序10-数论7
阅读程序10-数论7
阅读程序
注意:切勿用电脑直接运行代码得出答案,请用大脑+笔+纸运行代码答题,否则是在浪费你的时间。
第10节:数论
第7题【NOIP】2017
#include<iostream>
using namespace std;
int main() {
int n, m;
cin >> n >> m;
int x = 1;
int y = 1;
int dx = 1;
int dy = 1;
int cnt = 0;
while (cnt != 2) {
cnt = 0;
x = x + dx;
y = y + dy;
if (x == 1 || x == n) {
16 ++cnt;
17 dx = -dx;
}
if (y == 1 || y == m) {
20 ++cnt;
21 dy = -dy;
}
}
cout << x << " " << y << endl;
return 0;
}
●判断题
①)若将16、20行去掉,则程序会出现死循环
{{ select(7-1) }}
- 正确
- 错误
2)若将第一行的iostream改为cstdio,则程序会出现编译错误
{{ select(7-2) }}
- 正确
- 错误
(3)若将17、21行去掉,则程序会出现死循环
{{ select(7-3) }}
- 正确
- 错误
(4)记L=min(n,m),则时间复杂度为O()
{{ select(7-4) }}
- 正确
- 错误
●选择题
(5)输人2 3 1 1
,则输出()
{{ select(7-5) }}
- 1 1
- 2 2
- 1 3
- 3 1
(6)输入2 2 1 1
,则输出()
{{ select(7-6) }}
- 1 I
- 1 2
- 2 1
- 2 2