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: HELP!!在下新手,这个代码在我机子上可以运行,为什么提交就有问题呢,In Reply To: HELP!!在下新手,这个代码在我机子上可以运行,为什么提交就有问题呢, Posted by:snowfall at 2008-03-16 15:59:19 > #include<stdio.h> > #include<string.h> > main() > { > char str[51][101]; > char temp[100]; > int sum[101]; > int i,j,k,m,n,t; > > scanf("%d%d",&n,&m); > for(i=0;i<m;i++) > scanf("%s",&str[i]); > > for(i=0;i<m;i++) > sum[i]=0; > for(i=0;i<m;i++) > {for(j=0;j<n-1;j++) > {for(k=j+1;k<n;k++) > if(str[i][j]>str[i][k]) > sum[i]++; > } > } > > for(i=0;i<m-1;i++) > { for(j=i+1;j<m;j++) > > { if(sum[i]>sum[j]) > { strcpy(temp,str[i]); > strcpy(str[i],str[j]); > strcpy(str[j],temp); > t=sum[i]; > sum[i]=sum[j]; > sum[j]=t; > } > } > } > > for(i=0;i<m;i++) > printf("%s\n",str[i]); > > getchar(); > getchar(); > } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator