杭电acm2080
http://acm.hdu.edu.cn/showproblem.php?pid=2080
先用向量求出cosx,再用公式arcos(cosx)求得答案,,,,
View Code
1 #include <stdio.h> 2 3 4 #include <stdlib.h> 5 6 #include <math.h> 7 8 #define PI 3.141592653 9 10 int main() 11 12 { 13 14 int n; 15 16 double x1,x2,y1,y2,m,t; 17 18 scanf("%d",&n); 19 20 while(n--) 21 22 { 23 24 scanf("%lf%lf%lf%lf",&x1,&y1,&x2,&y2); 25 26 m=x1*x2+y1*y2; 27 28 t=sqrt((x1*x1+y1*y1)*(x2*x2+y2*y2)); 29 30 printf("%.2lf\n",acos(m/t)/PI*180);//这个是公式……不过也是网上来的 31 32 } 33 34 35 return 0; 36 37 }