hdu1700各位仁兄指点一下,测试数据对了就是wa解决思路

hdu1700各位仁兄指点一下,测试数据对了就是wa
本用用极坐标做的。
经过wa之后在网上找其他人的代码,没找到用极坐标的。
在下求教。
原题:http://acm.hdu.edu.cn/showproblem.php?pid=1700
Problem Description
There is a cycle with its center on the origin.
Now give you a point on the cycle, you are to find out the other two points on it, to maximize the sum of the distance between each other
you may assume that the radius of the cycle will not exceed 1000.
 

Input
There are T test cases, in each case there are 2 decimal number representing the coordinate of the given point.
 

Output
For each testcase you are supposed to output the coordinates of both of the unknow points by 3 decimal places of precision 
Alway output the lower one first(with a smaller Y-coordinate value), if they have the same Y value output the one with a smaller X. 


NOTE
when output, if the absolute difference between the coordinate values X1 and X2 is smaller than 0.0005, we assume they are equal.
 

Sample Input
2
1.500 2.000
563.585 1.251
 

Sample Output
0.982 -2.299 -2.482 0.299
-280.709 -488.704 -282.876 487.453

本人代码:
#include<stdio.h>
#include<math.h>
#define PI 3.14159265358

void main()
{
double d1,r,x1,x2,y1,y2;
int t;
scanf("%d",&t);
while(t--)
{
scanf("%lf%lf",&x1,&y1);
r=sqrt(x1*x1+y1*y1);
if(r!=0)
{
d1=asin(x1/r);
x2=r*sin(d1+2*PI/3);
y2=r*cos(d1+2*PI/3);
x1=r*sin(d1-2*PI/3);
y1=r*cos(d1-2*PI/3);
if(y2<y1)
{
r=y2;
y2=y1;
y1=r;
r=x1;
x1=x2;
x2=r;
}else if(y2==y2&&x2<x1)
{
r=y2;
y2=y1;
y1=r;
r=x1;
x1=x2;
x2=r;
}
}else x1=x2=y1=y2=0;
printf("%.3lf %.3lf %.3lf %.3lf\n",x1,y1,x2,y2);
}
}


欢迎各位指导,如是低级错误尽管骂我,不胜感谢。

------解决方案--------------------
语句
else if(y2==y2&&x2<x1)
中y2==y2打错了吧,其中一个应是y1.

如果要判浮点数y1与y2是否相等,不能用==,应改为abs(y1-y2)<=某个精度值。

------解决方案--------------------
我在3楼写abs是误导。对于double,应该用fabs.
LZ的计算有问题。请试以下输入:

2
1.500 -2.000
-1.500 -2.00

正确输出应是:
-2.482 -0.299 0.982 2.299
2.482 -0.299 -0.982 2.299