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 |
交了4次不想做了,反正水题,大家帮忙看下?#include <iostream> #include <stdio.h> #include <cmath> #include <algorithm> using namespace std; const double PI = 3.141592654; struct pt{ double x,y; }; double dist(pt& p1, pt& p2){ return sqrt((p1.x-p2.x)*(p1.x-p2.x)+(p1.y-p2.y)*(p1.y-p2.y)); } double jj(pt& p1, pt& p2, pt& p3){ return acos(((p1.x-p2.x)*(p3.x-p2.x)+(p1.y-p2.y)*(p3.y-p2.y))/dist(p1,p2)/dist(p3,p2))*180.0/PI; } double mx(double d1, double d2){ return (d1>d2)?d1:d2; } double mx(double d1, double d2, double d3){ return mx(mx(d1,d2),d3); } int main() { pt p1,p2,p3; while(scanf("%lf%lf%lf%lf%lf%lf",&p1.x,&p1.y,&p2.x,&p2.y,&p3.x,&p3.y) == 6){ double j1 = jj(p1,p2,p3), j2 = jj(p2,p3,p1), j3 = jj(p3,p1,p2); double b1 = dist(p1,p2), b2 = dist(p2,p3), b3 = dist(p3,p1); double mxj = mx(j1,j2,j3); if(mxj > 179.99) cout << "Not a Triangle" << endl; else{ double bs[3]; bs[0] = b1, bs[1] = b2, bs[2] = b3; sort(bs, bs+3); if(bs[2]-bs[0] < 0.1) cout << "Equilateral "; else if(bs[1]-bs[0] < 0.1 || bs[2]-bs[1] < 0.1) cout << "Isosceles "; else cout << "Scalene "; if(mxj > 90.1) cout << "Obtuse"; else if(mxj < 89.9) cout << "Acute"; else cout << "Right"; cout << endl; } } cout << "End of Output" << 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