| ||||||||||
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 |
这个水题和3623的题目是一模一样的,就是数据改了下,这个A了,3623就是送的In Reply To:终于A了,但是还是不明白为什么字母小的要排在前面 Posted by:denganliang at 2011-03-29 10:56:56 > #include <stdio.h> > #include <string.h> > int main(){ > int n,i,j,k,c,d,flag; > char a[2001],b[2001]; > memset(a,'\0',2001); > memset(a,'\0',2001); > scanf("%d",&n); > for(i=0;i<n;i++){ > getchar(); > a[i]=getchar(); > } > k=0; > if(n==1) { > printf("%c\n",a[0]); > return 0; > } > for(i=0,j=n-1;i<=j;){ > if(a[i]>a[j]){ > b[k++]=a[j--]; > } > else if(a[i]<a[j]){ > b[k++]=a[i++]; > } > else{ > flag=0; > if(i!=j){ > for(c=i+1,d=j-1;c<d;c++,d--){ > > if(a[c]>a[d]){ > b[k++]=a[j--]; > flag=1; > break; > } > else if(a[c]<a[d]){ > b[k++]=a[i++]; > flag=1; > break; > } > } > } > if(flag==0) b[k++]=a[i++]; > } > } > > b[k]='\0'; > for(i=0;i<n;){ > printf("%c",b[i]); > if((++i)%80==0) printf("\n"); > } > return 0; > } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator