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:194 at 2006-04-18 16:17:44 #include "string.h" main() {int i,j,k,m,n,t,b[100]; char a[100][50],temp[60],*p; ~~~~~a[100][51] scanf("%d %d",&n,&m); for(i=0;i<m;i++) {scanf("%s",a[i]); b[i]=0; for(j=0;j<n;j++) {for(k=j+1;k<n;k++) if(a[i][j]>a[i][k]) b[i]=b[i]+1; } } p=temp; for(i=0;i<m;i++) {for(j=i+1;j<m;j++) if(b[i]>b[j]) {t=b[i]; b[i]=b[j]; b[j]=t; strcpy(p,a[i]); strcpy(a[i],a[j]); strcpy(a[j],p); } } for(i=0;i<m;i++) printf("%s\n",a[i]); } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator