标签:
Time Limit: 1000MS | Memory Limit: 65536K | |
Total Submissions: 10523 | Accepted: 4882 |
Description
Input
Output
Sample Input
5 Xiaoming Xiaohua Xiaowang Zhangsan Lisi 2,3
Sample Output
Zhangsan Xiaohua Xiaoming Xiaowang Lisi
Source
模拟
做法一:
1 #include<cstdio> 2 #include<cmath> 3 #include<cstring> 4 #include<iostream> 5 #include<queue> 6 using namespace std; 7 struct point{ 8 string name; 9 int num; 10 }; 11 point p[65]; 12 int main(){ 13 int n,s,w; 14 while(cin>>n){ 15 int i=1; 16 for(;i<=n;i++){ 17 cin>>p[i].name; 18 p[i].num=i; 19 } 20 char c; 21 scanf("%d,%d",&w,&s);//输入尽量用scanf 22 //cout<<w<<" "<<s<<endl; 23 queue<int> st; 24 i=w; 25 int num=1; 26 for(;;i++){ 27 if(i==n+1){ 28 i=1; 29 } 30 if(p[i].num){ 31 if(num==s){ 32 //cout<<i<<endl; 33 num=1;//下一个数的编号 34 st.push(i); 35 p[i].num=0; 36 if(st.size()==n){ 37 break; 38 } 39 } 40 else{ 41 num++; 42 } 43 } 44 } 45 for(i=0;i<n;i++){ 46 cout<<p[st.front()].name<<endl; 47 st.pop(); 48 } 49 } 50 return 0; 51 }
做法二:
标签:
原文地址:http://www.cnblogs.com/Deribs4/p/4299236.html