题意翻译
题目描述 n(n<20)个人站成一圈,逆时针编号为 1~n。有两个官员,A从1开始逆时针数,B从n开始顺时针数。在每一轮中,官员A数k个就停下来,官员B数m个就停下来(两个官员有可能能停在同一个人上)。接下来被官员选中的1个或2个人离开队伍。
输入格式 输入n ,k ,m ,可能有多组数据,以 0 0 0结尾。
输出格式 输出每轮里被选中的人的编号(如果有两个人,先输出被A选中的)。输出的每个数应正好占3列。样例中的“ ␣ ”代表一个空格。
输入输出样例
输入 #1
10 4 3
0 0 0
输出 #1
␣␣4␣␣8,␣␣9␣
思路
设置一个数组,用来记录队伍中的编号是否出现过,设置一个变量,用来记录已经出现了多少编号了,设置两个变量,记录两个官员数到哪了.注意顺时针数的那个官员,可能会出现负数,变成负数则加上n.
代码
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main() {
int n;
int k;
int m;
int que[25];
while (1) {
scanf("%d%d%d", &n, &k, &m);
// 退出条件
if (n == 0) {
return 0;
}
int num &