#include<iostream>
#include<stack>
#include<queue>
using namespace std;
queue<int> q;
stack<int> s,ts;
int k;
int main()
{
int n,a;
cin>>n;
while(n--)
{
cin>>a;
q.push(a);
}
cin>>k;
int t=0;
while(!q.empty())
{
s.push(q.front());
q.pop();
t++;
if(t==k)
{
while(!s.empty())
{
cout<<s.top()<<' ';
s.pop();
}
t=0;
}
}
while(!s.empty())
{
ts.push(s.top());
s.pop();
}
while(!ts.empty())
{
cout<<ts.top()<<' ';
ts.pop();
}
return 0;
}
全部回复 共 0 条
还没有人回复。往下写第一条。
发表回复
登录后即可回复本帖,与出题人和同学一起讨论。
登录