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 |
哪位大牛帮忙看下,, 给下测试数据,怎么老wa?????代码: #include<stdio.h> #include<string.h> int main(int argc, char *argv[]) { int n,i,j,k,p,q,t,c=0; char a[30001]; scanf("%d",&n); j=0; for(i=0;i<n;i++) { getchar(); scanf("%c",&a[i]); } k=n-1; while(j<=k) { if(a[j]>a[k]) { printf("%c",a[k]); k--; c++; } else { printf("%c",a[j]); j++; c++; } if(a[j]==a[k]) { t = 1; p = j + 1; q = k - 1; while(p < q) { if(a[p] > a[q]) { t = 0; break; } else if(a[p] == a[q]) { p++; q--; } else break; } if(t) { printf("%c", a[j]); j++; c++; } else { printf("%c", a[k]); k--; c++; } } if(c%80==0) printf("\n"); } 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