STL

题目 :给出一组数,删除第一并作为第一位,下一个放置数列尾,重复操作,到删除到最后一个数,新数组为密码

 1 #include<iostream>
 2 #include<queue>
 3 using namespace std;
 4 
 5 queue<int> Q;
 6 
 7 int main()
 8 {
 9     for (int i = 0;i < 9;i++ )
10     {
11         int x;
12         cin >> x;
13         Q.push(x);
14     }
15     int i = 0,a[9];
16     while(!Q.empty())
17     {
18         a[i] = Q.front();
19         Q.pop();
20         Q.push(Q.front());
21         Q.pop();
22         i++;
23     }
24     for(int i = 0;i < 9;i++ )
25         cout << a[i] << " ";
26 }
原文地址:https://www.cnblogs.com/Dicer/p/8516270.html