程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> C語言 >> C++ >> 關於C++ >> ACdream1414 Geometry Problem

ACdream1414 Geometry Problem

編輯:關於C++

Problem Description

Peter is studying in the third grade of elementary school. His teacher of geometry often gives him difficult home tasks.
At the last lesson the students were studying circles. They learned how to draw circles with compasses. Peter has completed most of his homework and now he needs to solve the following problem. He is given two segments. He needs to draw a circle which intersects interior of each segment exactly once.
The circle must intersect the interior of each segment, just touching or passing through the end of the segment is not satisfactory.
Help Peter to complete his homework.

Input

The input file contains several test cases. Each test case consists of two lines.
The first line of the test case contains four integer numbers x11, y11, x12, y12— the coordinates of the ends of the first segment. The second line contains x21. y21, x22, y22 and describes the second segment in the same way.
Input is followed by two lines each of which contains four zeroes these lines must not be processed.
All coordinates do not exceed 102 by absolute value.

Output

For each test case output three real numbers — the coordinates of the center and the radius of the circle. All numbers in the output file must not exceed 1010 by their absolute values. The jury makes all comparisons of real numbers with the precision of 10-4.

Sample Input

0 0 0 4
1 0 1 4
0 0 0 0
0 0 0 0

Sample Output

0.5 0 2

Hint

\

Source

Andrew Stankevich Contest 22

這題是幾何題,先把線段的端點都連起來,共4條線段,然後選擇最短的那條線段,取這條線段的中點,中點即為圓心,半線段長為l1,算出這個點到另外兩點連線的較小長度l2,然後圓的半徑就是(l1+l2)/2;

 

#include
#include
#include
#include
#include
#include
#include
using namespace std;
#define inf 88888888
struct node{
	double dis,x,y,xx,yy;
}a[10];

struct student{
	double x,y;
}b[10];

double dist(double x,double y ,double xx,double yy){
	return sqrt((x-xx)*(x-xx)+(y-yy)*(y-yy));
}

bool cmp(node a,node b){
	double temp;
	if(a.dis>b.dis){
		temp=a.x;a.x=b.x;b.x=temp;
		temp=a.xx;a.xx=b.xx;b.xx=temp;
		temp=a.yy;a.yy=b.yy;b.yy=temp;
		temp=a.y;a.y=b.y;b.y=temp;
		return a.dis

 

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved