Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
用队列实现#include<iostream> #include<queue> using namespace std; int a[100]; int main() { int t,n,i,j; scanf("%d",&t); queue<int> q; while(t--) { scanf("%d",&n); q.push(n); for(i=n-1;i>=1;i--) { q.push(i); for(j=1;j<=i;j++) { int temp=q.front(); q.pop(); q.push(temp); } } int num=n-1; for(i=num;i>=0;i--) { a[i]=q.front(); q.pop(); } for(i=0;i<=num;i++) printf("%d ",a[i]); printf("\n"); } } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator