测评会员优惠活动进行中 · 开通 VIP,有效期内测评不限次 VIP 优惠中 · 测评不限次 立即查看

A61379. 2017年noip提高组初赛阅读程序题:#include <iostream>

填空题

题目描述

2017年noip提高组初赛阅读程序题:

#include <iostream>
usingnamespacestd;
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)
        {
            ++cnt;
            dx = -dx;
        }
        if (y == 1 || y == m)
        {
            ++cnt;
            dy = -dy;
        }
    }
    cout << x << " " << y << endl;
    return0;
}

输入 1:4 3 

输出 1:_________

输入 2:2017 1014 

输出 2:_________

输入 3:987 321 

输出 3:_________