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; }
相关文章推荐
- POJ 3750 小孩报数问题
- poj 3750 小孩报数问题 (约瑟夫问题)
- (顺序表应用5.1.1)POJ 3750 小孩报数问题(基本的约瑟夫环问题:给出人数n,出发位置w,间隔数s)
- poj 3750 小孩报数问题 约瑟夫问题
- POJ 3750 小孩报数问题
- poj 3750 小孩报数问题(模拟)
- poj 3750 小孩报数问题
- POJ 3750 小孩报数问题
- poj 3750 小孩报数问题(循环链表)
- poj 3750 小孩报数问题
- POJ 3750 小孩报数问题 模拟约瑟夫环
- (顺序表应用5.1.1)POJ 3750 小孩报数问题(基本的约瑟夫环问题:给出人数n,出发位置w,间隔数s)
- POJ 3750 小孩报数问题 G++
- poj 3750 小孩报数问题
- POJ 3750 小孩报数问题 (线性表思想 约瑟夫问题 数组模拟运算的 没用循环链表,控制好下标的指向就很容易了)
- 约瑟夫环 poj 3750 小孩报数问题 模拟
- POJ:题号3750----小孩报数问题
- poj 3750 小孩报数问题
- 约瑟夫环 poj 3750 小孩报数问题 模拟
- poj 3750 小孩报数问题