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?C语言#include"stdio.h" #include <stdlib.h> #include"string.h" main() {int n,m,i,j,k,c; long sum[51],d[51]; char a[100][51]; scanf("%d%d",&n,&m); for(i=0;i<m;i++) scanf("%s",&a[i]); 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]) printf("%s\n",a[j]); } } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator