卡片游戏(队列)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
#include<iostream> #include<queue> using namespace std; queue<int>q; int main() { int n; cin>>n; for(int i=1;i<=n;i++) q.push(i); while(!q.empty()) { cout<<q.front()<<' '; q.pop(); if(!q.empty()) { q.push(q.front()); q.pop(); } } return 0; } |
This article is automatically posted by WP-AutoPost : WordPress自动采集发布插件
如何获取并设置Cookie采集需要登录才能浏览的内容?,WP-AutoPost