| ||||||||||
| 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 | |||||||||
could you help me . i am puzzled. .....how to deal with this sentence
The final line of input will contain only a -1.
if the input data is -1 0 0 3 4 5 , how to deal with it , i am puzzled
this is my program , i don't know what 's wrong with it, could hawk give me some data to test it ?
thanks.
#include<iostream>
#include<cmath>
using namespace std;
const double ang=3.1415926/2;
double A,B;
double dis(double x1, double x2, double y1, double y2){
return sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
}
int main(){
int i,j,k,angle,len;
double x1,x2,x3,y1,y2,y3;
A=ang*88.0/90;
B=ang*92.0/90;
bool ok=true;
while(scanf("%lf",&x1)){
if (x1==-1) break;
scanf("%lf%lf%lf%lf%lf",&y1,&x2,&y2,&x3,&y3);
double a,b,c;
a=dis(x1,x2,y1,y2);
b=dis(x1,x3,y1,y3);
c=dis(x2,x3,y2,y3);
int ok1=0;
// cout<<a<<" "<<b<<" "<<c<<endl;
double x,y,z;
x=fabs(a-b);
y=fabs(a-c);
z=fabs(b-c);
// cout<<x<<" "<<y<<" "<<z<<endl;
if (a<=0.00001||b<=0.00001||c<=0.00001||a+b-c<0.001||a+c-b<0.001||b+c-a<0.001) ok1=0;
else if (x<=0.01&&y<=0.01&&z<=0.01) ok1=3;
else if (x<=0.01||y<=0.01||z<=0.01)ok1=2;
else ok1=1;
// cout<<ok1<<endl;
if (ok1>0){
double u,v,w;
u=acos((a*a+b*b-c*c)/(2*a*b));
v=acos((a*a+c*c-b*b)/(2*a*c));
w=acos((b*b+c*c-a*a)/(2*b*c));
int ok2=0;
// cout<<"A: "<<A<<" "<<"B: "<<B<<endl;
// cout<<u<<" "<<v<<" "<<w<<endl;
if ((u>=A&&u<=B)||(v>=A&&v<=B)||(w>=A&&v<=B)) ok2=2;
else if (u<A&&v<A&&w<A) ok2=1;
else ok2=0;
// cout<<ok2<<endl;
if (ok1==1) printf("Scalene");
else if (ok1==2) printf("Isosceles");
else printf("Equilateral");
if (ok2==1) printf(" Acute\n");
else if (ok2==2) printf(" Right\n");
else printf(" Obtuse\n");
}
else printf("Not a Triangle\n");
}
printf("End of Output\n");
return 0;
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator