Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

想了挺久。还是用最普通的想法水过。。。

Posted by xingchen12 at 2009-08-21 20:14:48 on Problem 3032
就是把它的步骤反过来做。。。
#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:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator