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

Re:为什么就是通不过呢?!!在我自己的机器上面都没有问题的.高手指点下拉

Posted by frkstyc at 2005-05-09 13:59:52 on Problem 1007
In Reply To:为什么就是通不过呢?!!在我自己的机器上面都没有问题的.高手指点下拉 Posted by:littlesky at 2005-05-09 13:58:46
注意要保证排序是稳定的

> #include <stdio.h>
> 
> main()
> {
> 	char a[100][51];
> 	int i,j,k,l,m,n,sum,min;
> 
> 	scanf("%d%d",&n,&m);
> 	for(i=0;i<=m-1;i++)
>         for(j=1;j<=n+1;j++)
> 	        scanf("%c",&a[i][j]);
> 	for(i=0;i<=m-1;i++)
> 	{
> 		sum=0;
> 		for(j=1;j<=n+1;j++)
> 			for(k=1;k<j;k++)
> 				if(a[i][j]<a[i][k])
> 					sum++;
> 		a[i][0]=sum;
> 	}
> 	for(i=0;i<=m-1;i++)
> 	{
> 		min=1500;
> 		for(j=0;j<=m-1;j++)
> 			if (a[j][0]!=-1)
> 			{
> 				if (a[j][0]<min)
> 				{
> 					min=a[j][0];
> 					k=j;
> 				}
> 			}
> 		a[k][0]=-1;
> 		for(l=1;l<=n+1;l++)
> 			printf("%c",a[k][l]);
> 	}
> 	printf("\n");
> }

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