您的位置:首页 > 其它

hoj2080夹角有多大II

2012-09-25 21:12 162 查看
//C++我CE了半天啊……苦逼啊
#include<stdio.h>
#include<math.h>
#define pi acos(-1)
typedef struct p{
double x,y;
}p;

double distant(p a,p b){
return (a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y);
}

int main(){
int t;
p a,b,c;
double q,w,e,s;
c.x=0.0;c.y=0.0;
scanf("%d",&t);
while(t--){
scanf("%lf%lf",&a.x,&a.y);
scanf("%lf%lf",&b.x,&b.y);
if(b.y/b.x==a.y/a.x){
if((b.y>0.0&&a.y<0.0)||(b.y<0.0&&a.y>0.0))
printf("180.00\n");
else printf("0.00\n");
}
else{
q=distant(a,c);
w=distant(b,c);
e=distant(a,b);
s=(double)(q+w-e)/(2.0*sqrt(1.0*q*w));
s=acos(s);
s=s*180/pi;
printf("%.2lf\n",s);
}
}
return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  struct c