Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

大神看看为什么错了啊,跪求答案!!!!!!!!!!!!!

Posted by yanyao5201314 at 2012-03-07 20:57:28 on Problem 1007
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<stdlib.h>
int main ()
{
	char a[60][200];
	int b[60],c[60];
	int i,j,k,m,n,t;
//	freopen("x.txt","r",stdin);
//	freopen("out.txt","w",stdout);
	while(scanf("%d%d",&n,&m)!=EOF)
	{
		for(i=0;i<m;i++)
			b[i]=0;
		for(i=0;i<m;i++)
		   	c[i]=i;	
		for(i=0;i<m;i++)	
		scanf("%s",a[i]);
		for(i=0;i<m;i++)
		{
			for(j=0;j<n;j++)
			{
				for(k=j+1;k<n;k++)
				{
					if(a[i][j]>a[i][k])
					 b[i]++;
				}
			}
		}
	//	for(i=0;i<m;i++)
	//		printf("%d\n",b[i]);
		for(i=0;i<m-1;i++)
			for(j=0;j<m-1-i;j++)
			{
				if(b[j]>b[j+1])
				{
					t=b[j];
					b[j]=b[j+1];
					b[j+1]=t;
					t=c[j];
					c[j]=c[j+1];
					c[j+1]=t;
				}
			}
	//	for(i=0;i<m;i++)
	//	printf("%d\n",c[i]);	
		for(i=0;i<m;i++)
		printf("%s\n",a[c[i]]);	
	}
	

    return 0;
}

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator