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 |
求指点!MS上都正确,一直WA,看不出问题在哪儿。。。#include<stdio.h> int sort(char s[],int n) { int i,j,k=0; for(i=0;i<n;i++) for(j=i+1;j<n;j++) if(s[i]>s[j]) k++; return k; } int main() { int m,n; printf("enter m(0<m<=100),n(0<n<=50)\n"); scanf("%d%d",&m,&n); char s[101][51]; int rank[101]; int i,j; for(i=0;i<m;i++) { scanf("%s",s[i]); rank[i]=sort(s[i],n); } int *p[101],*temp; for(i=0;i<m;i++) p[i]=&rank[i]; for(i=0;i<m;i++) for(j=m-1;j>i;j--) if(*p[j]<*p[j-1]) { temp=p[j]; p[j]=p[j-1]; p[j-1]=temp; } printf("the arrangement is:\n"); for(i=0;i<m;i++) printf("%s\n",s[p[i]-rank]); return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator