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 caiyuxua at 2007-04-11 21:49:38 on Problem 2007
#include<iostream.h>
void main()
{
	int x[51],y[51],xx[51],yy[51],i=0,ii=0,a,b,m,n,f[51],max,p,c,d;
	for(m=0;m<50;m++)f[m]=m;
	m=0;
	double t[51],tt[51];
	cin>>c>>d;
	while(cin>>a>>b)
	{
		if(	a-c<0	&&	b-d<0	)
		{
			xx[ii]=a;
			yy[ii]=b;
			tt[ii]=double(b-d)/(a-c);
			ii++;
		}
		else
		{
			x[i]=a;
			y[i]=b;
			t[i]=double(b-d)/(a-c);
			i++;
		}
	}
	for(m=0;m<ii;m++)
	{
		max=m;
		for(n=m+1;n<=ii;n++)
		{
			if(tt[f[n]]>tt[f[max]])max=n;
		}
		p=f[max];
		f[max]=f[m];
		f[m]=p;
	}
	cout<<'('<<c<<','<<d<<")\n";
	for(m=ii-1;m>=0;m--)cout<<'('<<xx[f[m]]<<','<<yy[f[m]]<<')'<<endl;
	for(m=0;m<50;m++)f[m]=m;
	for(m=0;m<i;m++)
	{
		max=m;
		for(n=m+1;n<=i;n++)
		{
			if(t[f[n]]>t[f[max]])max=n;
		}
		p=f[max];
		f[max]=f[m];
		f[m]=p;
	}
	for(m=i-1;m>=0;m--)cout<<'('<<x[f[m]]<<','<<y[f[m]]<<')'<<endl;
}

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