poj 3750 小孩报数问题

#include<iostream>
#include
<string>
#include
<vector>
using namespace std;
struct Node
{
int index;
string str;
Node(
int i,string s)
{
index
=i;str=s;
}
};
vector
<Node> table;
int main()
{
int n,w,s,i,ans;
string str;
cin
>>n;
for (i=1;i<=n;++i)
{
cin
>>str;
Node node(i,str);
table.push_back(node);
}
scanf(
"%d,%d",&w,&s);
w
--;
while(!table.empty())
{
ans
=(w+s-1)%table.size();
cout
<<table[ans].str<<endl;
w
=(ans==table.size()-1)?0:ans;
table.erase(table.begin()
+ans);
}
return 0;
}

  

posted on 2011-07-22 16:52  sysu_mjc  阅读(156)  评论(0编辑  收藏  举报

导航