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" void main() {int n,m,i,j,k,sum[100],d[50],c; char a[100][50]; scanf("%d %d\n",&n,&m); for(i=0;i<m;i++) {for(j=0;j<n;j++) scanf("%c",&a[i][j]); if (i!=m-1) scanf("\n"); } for(i=0;i<m;i++) {sum[i]=0; for(j=0;j<n-1;j++) for(k=j+1;k<n;k++) if(a[i][j]>a[i][k]) sum[i]=sum[i]+1; } for(i=0;i<m;i++) d[i]=sum[i]; for(i=1;i<m;i++) for(j=0;j<m-i;j++) if(d[j]>d[j+1]) {c=d[j]; d[j]=d[j+1]; d[j+1]=c; } for(i=0;i<m;i++) {if(d[i]==d[i+1]) continue; for(j=0;j<m;j++) if(d[i]==sum[j]) {for(k=0;k<n;k++) printf("%c",a[j][k]); printf("\n"); } } } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator