标签:style blog http io ar color os sp for
题目地址:1931. 卡片游戏
思路:
纯属数据结构中队列的应用,可以练练手。
具体代码如下:
1 #include <iostream> 2 #include <queue> 3 using namespace std; 4 5 int main() { 6 int t; 7 cin >> t; 8 while (t--) { 9 int num; 10 cin >> num; 11 queue<int> store; 12 for (int i = 1; i <= num; i++) { 13 store.push(i); 14 } 15 for (int i = 1; i <= num; i++) { 16 cout << store.front() << " "; 17 store.pop(); 18 int temp = store.front(); 19 store.pop(); 20 store.push(temp); 21 } 22 cout << endl; 23 } 24 25 return 0; 26 }
标签:style blog http io ar color os sp for
原文地址:http://www.cnblogs.com/winray/p/4109544.html