poj 3750 小孩报数问题

来源:互联网 发布:淘宝店铺永久封了 编辑:程序博客网 时间:2024/06/11 09:15
#include <iostream>#include <cstdio>#include <string>#include <queue>using namespace std;int main(){    int num, w, s, i, c;    string name, tmp;    queue<string> q;    queue<string> ans;    cin >> num;    for (i = 0; i < num; i++){        cin >> name;        q.push(name);    }    scanf("%d,%d", &w, &s);    //cin >> w >> s;        //cout << q.size() << endl;    c = 0;    while (q.size() != 0){           tmp = q.front();           c++;           if (c == w)               break;           else{               q.pop();               q.push(tmp);           }    }    //cout << q.size() << endl;    c = 0;    while (q.size() >= s){          tmp = q.front();          c++;          q.pop();          if (c == s){              ans.push(tmp);              c = 0;          }          else{               q.push(tmp);          }    }        while (q.size() != 0){          tmp = q.front();          q.pop();          ans.push(tmp);    }        while (ans.size() != 0){          tmp = ans.front();          ans.pop();          cout << tmp << endl;    }        system("pause");}

原创粉丝点击