计算几何 The Circumference of the Circle
来源:互联网 发布:mac版vmware fusion 编辑:程序博客网 时间:2024/05/20 18:01
To calculate the circumference of a circle seems to be an easy task - provided you know its diameter. But what if you don't?
You are given the cartesian coordinates of three non-collinear points in the plane.
Your job is to calculate the circumference of the unique circle that intersects all three points.
输入
The input will contain one or more test cases. Each test case consists of one line containing six real numbers x1,y1, x2,y2,x3,y3, representing the coordinates of the three points. The diameter of the circle determined by the three points will never exceed a million. Input is terminated by end of file.
输出
For each test case, print one line containing one real number telling the circumference of the circle determined by the three points. The circumference is to be printed accurately rounded to two decimals. The value of pi is approximately 3.141592653589793.
样例输入
样例输出
题目来源
ULM 1996
程序代码:
#include <iostream>#include <cmath>#include <iomanip>using namespace std;const double pi=3.141592653589793;int main(){double x1,y1,x2,y2,x3,y3,a,b,c,st,cir,r,p;while(cin>>x1>>y1>>x2>>y2>>x3>>y3){a=sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));b=sqrt((x1-x3)*(x1-x3)+(y1-y3)*(y1-y3));c=sqrt((x3-x2)*(x3-x2)+(y3-y2)*(y3-y2));p=(a+b+c)/2;st=sqrt(p*(p-a)*(p-b)*(p-c));//三角形面积,海伦公式r=a*b*c/(4*st);cir=2*pi*r;cout.setf(ios::fixed);cout.precision(2);cout<<cir<<endl;}return 0;}cout.setf(ios::fixed);不设置为定点小数的话,cout.precision(2)指的是有效位数为2,如3.1;设置为定点小数后,cout.precision(2)指的是小数有效位数为2,如3.14
- 计算几何 The Circumference of the Circle
- The Circumference of the Circle(计算几何)
- POJ 2242 The Circumference of the Circle (计算几何)
- UVa 438 The Circumference of the Circle (计算几何)
- UVA 438 - The Circumference of the Circle(计算几何)
- HDU 1374 The Circumference of the Circle 计算几何
- 438 - The Circumference of the Circle【几何】
- uva 438 - The Circumference of the Circle(几何)
- The Circumference of the Circle
- POJ2242_The Circumference of the Circle(几何/三角形外接圆周长/模板)
- pku2242The Circumference of the Circle
- zoj1090 The Circumference of the Circle
- ZOJ1090 The Circumference of the Circle
- POJ 2242 The Circumference of the Circle
- poj 2242 The Circumference of the Circle
- zoj 1090 The Circumference of the Circle
- HOJ 1439 The Circumference of the Circle
- UVa 438 - The Circumference of the Circle
- Redis之十六 Sentinel(哨兵)
- auto和decltype的用法总结
- HDOJ-----1950Bridging signals(LIS)
- Redis之十七 集群
- 2、数据库事务
- 计算几何 The Circumference of the Circle
- HDU 1394 Minimum Inversion Number
- Mac系统安装MATLAB 2015b 破解版
- Redis之十八 事务
- RecatNative环境配置
- fast-framework – 基于 JDK 8 实现的 Java Web MVC 框架
- eclipse查看类源码出现failed to create the part's controls的解决方法
- Java中native关键字
- string 和 char *两者的区别是什么 ?