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 nan212 at 2007-08-18 09:33:42 on Problem 1922
#include<iostream.h>
#include<math.h>
struct student
{
	double v;
	double st;
	double arr;
};
int compare(student a,student b)
{
	if(a.st>b.st&&a.v>b.v)
			return 1;
	return 0;
}
int main()
{
	int n,a,b;
	cin>>n;
	while(n!=0&&n>=1&&n<=10000)
	{
		student *p=new student[n];
		for(int i=0;i<n;i++)
		{
			cin>>a>>b;
			p[i].v=a/3.6;
			p[i].st=b;
			p[i].arr=4500/p[i].v+b;
		}
		student x;
		int k;
		for(i=1;i<=n-1;i++)
		{
			k=i-1;
			for(int j=i;j<=n-1;j++)
			{
				if(p[j].arr<p[k].arr)
					k=j;
			}
			if(k!=i-1)
			{
				x=p[i-1];
				p[i-1]=p[k];
				p[k]=x;
			}
		}
		for( i=1;i<n;i++)
		{
			if(compare(p[i],p[i-1]))
				continue;
			else break;
		}
		cout<<ceil(p[i-1].arr)<<endl;
		cin>>n;
	}
	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