| ||||||||||
| 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>
using namespace std;
int main(){
int N,x,i,j,k,t,a[100];
cin>>N;
while(N--){
cin>>x;
a[x-1]=x;
for(i=x-1;i>=1;i--){
a[i-1]=i;
for(j=1;j<=i;j++){ //翻转
t=a[x-1];
for(k=1;k<=x-i;k++){
a[x-k]=a[x-k-1];
}
a[i-1]=t;
}
}
for(i=0;i<x;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