题目:这次xhd面临的问题是这样的:在一个平面内有两个点,求两个点分别和原点的连线的夹角的大小。
#include<stdio.h>
#include<math.h>
#define pi 3.1415926
main(){
double s,a,b,x1,x2,y1,y2;
int n;
scanf("%d",&n);
while(n--){
scanf("%lf %lf %lf %lf",&x1,&y1,&x2,&y2);
a=sqrt(x1*x1+y1*y1);
b=sqrt(x2*x2+y2*y2);
s=acos((x1*x2+y1*y2)/(a*b))/pi*180;
printf("%.2lf\n",s);
}
return 0;
}
注意:要用double类型控制精度。