因爲題目不是用英語描述的,我就不解釋題意了(假如看不懂,你要審視自己是否適合幹這行)。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;
}