因为题目不是用英语描述的,我就不解释题意了(假如看不懂,你要审视自己是否适合干这行)。O(∩_∩)O哈哈~
思路:简单的模拟题,但要想好其报数过程与代码实现的结合(有好多细节要注意)。
代码如下:
#include<iostream>
using namespace std;
char name[65][16];
bool out[65];
int main()
{
int n,w,s;
scanf("%d",&n);
for(int i=1;i<=n;i++)
scanf("%s",name[i]);
scanf("%d,%d",&w,&s);
memset(out,0,sizeof(out));
int in=n;
while(in>0)
{
int step=(s-1)%n; //要找出移动的步数,为了把循环的省去所以选择求余。
while(out[w]) //确定下一步的起点。
{
w++;
if(w>n) w=1; //使其可以循环(很重要的细节)。
}
while(step>0) //模拟向下的过程
{
w++;
if(w>n) w=1;
if(!out[w]) step--;
}
out[w]=true;
printf("%s\n",&name[w]);
in--;
}
return 0;
}