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 stupidjohn at 2010-05-30 00:00:55 on Problem 1007
#include<stdio.h>
int m,n;
char array[100][51];
int sort[100][2];
void input(int k)
{
	int i,j,tcount=0;
	for(i=0;i<n;i++)
	{
		scanf("%c",&array[k][i]);
		for(j=0;j<i;j++)
		if(array[k][j]>array[k][i])
			tcount++;
	}
	array[k][i]='\0';
	sort[k][0]=tcount;
	sort[k][1]=0;
}
int find()
{
	int i,ti=0,min=999999;
	for(i=0;i<m;i++)
	{
		if((sort[i][1]==0)&&(sort[i][0]<min))
		{
			min=sort[i][0];
			ti=i;
		}
	}
	sort[ti][1]=1;
	return ti;
}
void run()
{
	int i,ti;
	scanf("%d%d",&n,&m);
	getchar();
	for(i=0;i<m;i++)
	{
		input(i);
		getchar();
	}
	for(i=0;i<m;i++)
	{
		ti=find();
		puts(array[ti]);
	}
}
int main()
{
	run();
	return 1;
}


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