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 church at 2007-05-21 21:27:44 on Problem 2242
#include <stdio.h>
#include <math.h>

#define p 3.141592653589793
void main()
{
	float x,y,x1,y1,x2,y2,k,k1,mx,my,mx1,my1,xx,yy,c;
	
	while (scanf("%f %f %f %f %f %f",&x,&y,&x1,&y1,&x2,&y2)!=EOF)
	{
		if (y!=y1)
		{
			k=-(x-x1)/(y-y1);
			mx=(x+x1)/2;  my=(y+y1)/2;
			if (y!=y2)
			{
				k1=-(x-x2)/(y-y2);
				mx1=(x+x2)/2; my1=(y+y2)/2;
				xx=(my1-my+k*mx-k1*mx1)/(-(x-x1)/(y-y1)+(x-x2)/(y-y2));
				yy=-(x-x1)/(y-y1)*((my1-my+k*mx-k1*mx1)/(-(x-x1)/(y-y1)+(x-x2)/(y-y2))-mx)+my;
			
			}
			else
			{
				xx=(x+x2)/2;
				yy=(x2-x1)/2*(x1-x)/(y-y1)+(y+y1)/2;
			}
		}
		else
		{
			xx=(y+x1)/2;
			k1=-(x-x2)/(y-y2);
			mx1=(x+x2)/2; my1=(y+y2)/2;
			yy=((y+x1)/2-(x+x2)/2)*((x2-x)/(y-y2))+(y+y2)/2;
		}
		c=2*p*sqrt((xx-x)*(xx-x)+(yy-y)*(yy-y));
		printf("%0.2f\n",c);
	}
}

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