Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
g++ 不能用long double 否则 WR 用double 才可以 c++无所谓#include <iostream> #include <cmath> using namespace std; int main() { long double x1,x2,x3,y1,y2,y3,a,b,c,perimeter,s,aver; 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) ); aver = (a+b+c) / 2.0 ; s = sqrt( aver*(aver-a)*(aver-b)*(aver-c) ); perimeter = 3.141592653589793 * a * b * c / (2 * s); cout.setf(ios::fixed); cout.precision(2); cout << perimeter << endl; } return 0; } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator