第1个回答 2014-07-05
#include<iostream> #include<cmath> using namespace std; int Cal(int x1,int y1,int x2,int y2) { return (x1-x2)*(x1-x2)+(y1-y2)*(y1-y2); } int check(int a,int b,int c) { return (a+b-c); } int main() { freopen("A-large.in","r",stdin); freopen("A large.out","w",stdout); int n,i; int x1,x2,x3,y1,y2,y3; int a,b,c; cin>>n; for(i=1;i<=n;i++) { cin>>x1>>y1>>x2>>y2>>x3>>y3; a=Cal(x1,y1,x2,y2); b=Cal(x2,y2,x3,y3); c=Cal(x3,y3,x1,y1); if((sqrt(a)+sqrt(b)-sqrt(c)<=0)||(sqrt(a)+sqrt(c)-sqrt(b)<=0)||(sqrt(b)+sqrt(c)-sqrt(a)<=0)||(a==0)||(b==0)||(c==0)) cout<<"Case #"<<i<<": not a triangle"<<endl; else { if((check(a,b,c)>0)&&(check(a,c,b)>0)&&(check(b,c,a)>0)) { if((a==b)||(b==c)||(c==a)) cout<<"Case #"<<i<<": isosceles acute triangle"<<endl; else cout<<"Case #"<<i<<": scalene acute triangle"<<endl; } else if((check(a,b,c)==0)||(check(a,c,b)==0)||(check(b,c,a)==0)) { if((a==b)||(b==c)||(c==a)) cout<<"Case #"<<i<<": isosceles right triangle"<<endl; else cout<<"Case #"<<i<<": scalene right triangle"<<endl; } else { if((a==b)||(b==c)||(c==a)) cout<<"Case #"<<i<<": isosceles obtuse triangle"<<endl; else cout<<"Case #"<<i<<": scalene obtuse triangle"<<endl; } } } fclose(stdin); fclose(stdout); return 0; }