题目链接:http://codeforces.com/problemset/problem/659/A
在一个环中是按照升序方向走还是按照降续方向走
AC代码:
#include<cstdio>
#include<algorithm>
using namespace std;
int main() {
int n, a, b;
bool flag;
while (scanf("%d%d%d", &n, &a, &b) != EOF) {
if(b<0)
flag = true;
else
flag = false;
b = abs(b);
int route = b % n;
if (flag) {
while (route != 0) {
a--;
if (a < 1) {
a = n;
}
route--;
}
}
else {
while (route != 0) {
a++;
if (a > n)
a = 1;
route--;
}
}
printf("%d
", a);
}
return 0;
}