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

为什么会wa

Posted by 516460452 at 2011-12-02 11:16:04 on Problem 1007
#include<stdio.h>
int main()
{
	int a[51],b[51],n,m,i,j,k,min,temp;
	char s[51][101];
	scanf("%d%d",&m,&n);
	getchar();
	for(i=0;i<n;i++)
		a[i]=0;
	for(i=0;i<n;i++)
	{
		gets(s[i]);
		for(j=0;j<m-1;j++)
			for(k=j+1;k<m;k++)
				if(s[i][j]>s[i][k])
					a[i]++;
	}
	for(i=0;i<n;i++)
		b[i]=a[i];
	for(i=0;i<n;i++)
	{
		min=i;
		for(j=i+1;j<n;j++)
			if(a[j]<a[min])
				min=j;
		temp=a[min];
		a[min]=a[i];
		a[i]=temp;
	}
	for(i=0;i<n;i++)
		for(j=0;j<n;j++)
			if(a[i]==b[j])
			{
				puts(s[j]);
				b[j]=-1;
				break;
			}
	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