/*
* POJ_3750.cpp
*
* Created on: 2013年10月30日
* Author: Administrator
*/
#include <iostream>
#include <cstdio>
using namespace std;
const int maxn = 70;
int main(){
char name[maxn][maxn];//小孩名字
int p[maxn];//小孩序号
int n;
scanf("%d",&n);
int i;
for(i = 0 ; i < n ; ++i){
p[i] = i;
scanf("%s",&name[i]);
}
int w,s;
scanf("%d,%d",&w,&s);
w = (w + n - 1 )%n;//出发位置
do{
w = (w + s - 1)%n;//出列位置
cout<<name[p[w]]<<endl;
int j;
for(j = w ; j < n - 1 ; ++j){//将出列位置后元素向前移动
p[j] = p[j+1];
}
}while(--n);
}
(顺序表应用5.1.1)POJ 3750 小孩报数问题(基本的约瑟夫环问题:给出人数n,出发位置w,间隔数s)...
最新推荐文章于 2020-02-15 11:23:48 发布