Sep 8, 2018 at 3:24pm UTC
Might be a problem with comparison of floating point numbers.
Why don't you print the vars and result and show us what you got.
Sep 8, 2018 at 5:45pm UTC
Ok, now I avoid double and float. But I am still getting the wrong answer.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
#include<iostream>
#include<math.h>
using std::cout;
using std::cin;
int main()
{
int t;
cin>>t;
int x1,y1,r1,x2,y2,r2;
while (t>0)
{
cin>>x1>>y1>>r1>>x2>>y2>>r2;
int sqdist=(((x1-x2)*(x1-x2))+((y1-y2)*(y1-y2)));
if (r2<r1)
{
cout<<"O" ;
if (t!=1)
cout<<std::endl;
t-=1;
continue ;
}
else
{
if (sqdist==(r2-r1)*(r2-r1))
cout<<"E" ;
else if (sqdist<(r2-r1)*(r2-r1))
cout<<"I" ;
else
cout<<"O" ;
}
if (t!=1)
cout<<std::endl;
t-=1;
}
}
Last edited on Sep 8, 2018 at 5:45pm UTC