第七题(NOIP2017)
#include<iostream>
using namespace std;
int main() {
int n,m;
cin>>n>>m;
int x=1, y=1;
int dx=1, dy=1;
int cnt=0;
while (cnt!=2) {
cnt=0;
x=x+dx;
y=y+dy;
if(x==1 || x==n) {
++cnt;
dx=-dx;
}
if(y==1 || y==m) {
++cnt;
dy=-dy;
}
}
cout<<x<<" "<<y<<endl;
return 0;
}
- 【判断题】若将16、20行去掉,则程序会出现死循环。
{{ select(1) }}
- 【判断题】若将第一行的iostream改为cstdio,则程序会出现编译错误。
{{ select(2) }}
- 【判断题】若将17、21行去掉,则程序会出现死循环。
{{ select(3) }}
- 【判断题】记 L=min(n,m) ,则时间复杂度为 O(L2) 。
{{ select(4) }}
- 【选择题】输入2 3,则输出( )。
{{ select(5) }}
- 【选择题】输入2 2,则输出( )。
{{ select(6) }}