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 |
Re:笨方法,但能想到的数据都过过了,怎么一直wa,求教!!!!!In Reply To:笨方法,但能想到的数据都过过了,怎么一直wa,求教!!!!! Posted by:xulinxi at 2010-08-17 11:50:19 > #include<cstdio> > #include<cstring> > #include<algorithm> > using namespace std; > > int main() > { > > int n,i,k=0,p,j,flag=0; > char a[3000],b[3000]; > > scanf("%d",&n); > > > for(i=0;i<n;i++) > scanf("\n%c",&a[i]); > > > p=0; > for(i=0;i<n;++i) > { > if(flag) > { > i--; > } > if(p==n) > break; > for(j=n-1-k;j>=0;j--) > { > if(a[i]>a[j]) > { > b[p]=a[j]; > p++; > flag=1; > k++; > break; > } > if(a[i]==a[j]&&(i!=j)) > { > if(a[i+1]>a[j-1]) > { > b[p]=a[j]; > p++; > flag=1; > k++; > break; > } > b[p]=a[i]; > p++; > flag=0; > break; > } > b[p]=a[i]; > p++; > flag=0; > break; > } > } > for(i=0;i<n;i++) > { > if(i%80==79) > printf("\n"); > printf("%c",b[i]); > > } > > > return 0; > } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator