天生我材必有难,千金散尽还债来 • 1年前
#include<iostream>
#include<list>
#include<stack>
using namespace std;
int main() {
list<int> a;
stack<int> b;
int n,j;
cin>>n;
for(int k=0; k<n; k++) {
int c;
cin>>c;
a.push_back(c);
}
cin>>j;
int y=a.size()%j;
int x=a.size();
for(int k=0; k<(x-y)/j; k++) {
for(int k=0; k<j; k++) {
b.push(a.front());
a.pop_front();
}
for(int k=0; k<j; k++) {
cout<<b.top()<<" ";
b.pop();
}
}
if(y!=0) {
for(auto n:a) {
cout<<n<<" ";
}
}
return 0;
}
评论:
请先登录,才能进行评论