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?C语言In Reply To:求大牛帮忙看下哪错了,为什么老是WA?C语言 Posted by:20054953 at 2007-01-18 20:11:09 > #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