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 |
庆祝我的第200道AC题目,HOHO#include<iostream.h> #include<string.h> int main() { int T,n; int a[15],temp[15]; cin>>T; while(T--) { cin>>n; if(n==1) {cout<<1<<endl;} else { int t,i,j,k; t=k=0; memset(temp,0,sizeof(temp)); for(i=1;i<=n;i++) { j=0; while(j<i) { j++;t++; if(t==n) t=0; while(temp[t]==1) { t++; if(t==n) t=0; } } temp[t]=1;a[t++]=i;k++; if(t==n) t=0; while(temp[t]==1&&k<n) { t++; if(t==n) t=0; } } for(i=0;i<n;i++) cout<<a[i]<<" "; cout<<endl; } } return 0; } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator