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

为什么sample是对的,结果却是wrong answer呢?呜,哪位大侠能普渡一下。

Posted by Kenneth at 2005-09-09 21:38:37 on Problem 1007
#include<stdio.h>
void main()
{
	char a[100][50];
	int i,j,k,aa[100],m,n,aaa[100];
	scanf("%d %d",&n,&m);
	for(i=0;i<m;i++)
	{
		scanf("%s",a[i]);
		aa[i]=0;
		aaa[i]=i;
	}
	for(i=0;i<m;i++)
		for(j=0;j<n-1;j++)
			for(k=j+1;k<n;k++)
				if(a[i][j]>a[i][k])
					aa[i]++;
	for(i=0;i<m-1;i++)
		for(j=i+1;j<m;j++)
			if(aa[i]>aa[j])
			{
				k=aa[i];
				aa[i]=aa[j];
				aa[j]=k;
				k=aaa[i];
				aaa[i]=aaa[j];
				aaa[j]=k;
			}
	for(i=0;i<m;i++)
	{
		k=aaa[i];
		printf("%s\n",a[k]);
	}
}

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