1#include <iostream>2#include <cstdio>3#include <cstring>4 using namespacestd;5 inta[ to],n;6 7 voidRev (intCT) {8printf"%d", N-CT);9 for(intI=0; i<=ct/2;++i)TenSwap (a[i],a[ct-i]); One } A - intScan () - { the CharCh=0; -Memset (A,0,sizeof(a)); - if(SCANF ("%d", &a[0])==EOF) - return 0; + intI=1; - while((Ch=getchar ()) &&ch!='\ n') +scanf"%d", &a[i++]); A returni; at } - intMain () - { - while(n=Scan ()) - { -printf"%d", a[0]); in for(intI=1; i<n;++i) -printf"%d", A[i]); toprintf"\ n"); + intCnt=N; - while(CNT) the { * intmaxn=0, Flag; $ for(intI=0; i<cnt;++i)Panax Notoginseng { - if(a[i]>MAXN) the { +maxn=A[i]; Aflag=i; the } + } - if(flag!=cnt-1) $ { $ if(flag!=0) - rev (flag); -Rev (cnt-1); the } -cnt--;Wuyi } theprintf"0\n"); - } Wu return 0; -}
Test instructions: give a number of series, one can only let the first to the second sequence of all reversal, require the order of the sequence of ascending.
Uva120 Stacks of Flapjacks