1 #include <iostream> 2 #include <cmath> 3 #include <cstdio> 4 using namespace std; 5 const double pi=3.14159265; 6 struct Point 7 { 8 double x,y; 9 //Point(int X,int Y):x(X),y(Y){}; 10 }; 11 inline double function_1(double hd) 12 { 13 return 180/pi*hd; 14 } 15 inline double function_2(Point p) 16 { 17 if(p.x>=0&&p.y>=0) 18 return function_1(atan(p.y/p.x)); 19 else if(p.x<0&&p.y>=0) 20 return function_1(atan(p.y/p.x))+180; 21 else if(p.x<0,p.y<=0) 22 return function_1(atan(p.y/p.x))+180; 23 else 24 return function_1(atan(p.y/p.x))+360; 25 } 26 int main() 27 { 28 int n; 29 cin>>n; 30 while(n--) 31 { 32 Point p1,p2; 33 double o=0; 34 cin>>p1.x>>p1.y>>p2.x>>p2.y; 35 //cout<<function_2(p1)<<" "<<function_2(p2)<<endl; 36 o=abs(function_2(p1)-function_2(p2)); 37 //cout<<o<<endl; 38 printf("%.2lf\n",o); 39 40 } 41 return 0; 42 }
原文:http://www.cnblogs.com/Twobox/p/6506527.html