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 |
怀疑就别做了In Reply To:我都怀疑这个网站的可信度了! Posted by:erics at 2005-07-30 15:36:41 > #include <stdio.h> > #include <string.h> > void main() > { > char str[100][51],b[100],a[51]; > int col,row,i,j,i1,j1,count,sum,temp; > scanf("%d%d",&col,&row); > for(i=0;i<row;i++) > { > str[i][0]=getchar();sum=0; > for(j=0;j<col;j++) > str[i][j]=getchar(); > str[i][col]='\0'; > > for(i1=col-1;i1>=0;i1--) > { > count=0; > for(j1=0;j1<i1;j1++) > if(str[i][j1]>str[i][i1]) count++; > sum+=count; > } > b[i]=sum; > > } > > for(i=0;i<=row-2;i++) > for(j=i+1;j<=row-1;j++) > if(b[i]>b[j]) > { > strcpy(a,str[i]);temp=b[i]; > strcpy(str[i],str[j]);b[i]=b[j]; > strcpy(str[j],a);b[j]=temp; > } > for(i=0;i<row;i++) > printf("%s\n",str[i]); > } > 在机上没问题,可一提交就wa. Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator