您的位置:首页 > 其它

poj 3750 小孩报数问题

2011-07-22 16:52 330 查看
#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;
}


  
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: