简单题,不解释,不过,貌似我现在也就能做做简单的数学题了。
#include<cstdio> #include<cstring> #include<algorithm> #include<cmath> const double pi=acos(-1.0); using namespace std; void f(double &angle,double x,double y) { if(x<0&&y<0) angle+=180.0; else if(x>=0&&y<0) angle+=360.0; else if(x<0&&y>=0) angle+=180.0; } int main() { int t; double x1,y1,x2,y2; scanf("%d",&t); while(t--) { scanf("%lf%lf%lf%lf",&x1,&y1,&x2,&y2); double angle1=atan(y1/x1)*180.0/pi; double angle2=atan(y2/x2)*180.0/pi; f(angle1,x1,y1); f(angle2,x2,y2); //printf("%lf,%lf\n",angle1,angle2); double d=angle1-angle2; //printf("d=%lf\n",d); if(d<0) d=-d; if(d>180) d=360-d; printf("%.2lf\n",d); } return 0; }
时间: 2024-10-24 01:04:14