hdu 2080

来源:互联网 发布:义隆单片机c语言教程 编辑:程序博客网 时间:2024/06/01 08:29

夹角有多大II
Time Limit: 1000msMemory Limit: 32768KB This problem will be judged on HDU. Original ID: 2080
64-bit integer IO format: %I64d Java class name: Main
Prev Submit Status Statistics Next
Type:
None

Tag it!
这次xhd面临的问题是这样的:在一个平面内有两个点,求两个点分别和原点的连线的夹角的大小。

注:夹角的范围[0,180],两个点不会在圆心出现。
Input
输入数据的第一行是一个数据T,表示有T组数据。
每组数据有四个实数x1,y1,x2,y2分别表示两个点的坐标,这些实数的范围是[-10000,10000]。
Output
对于每组输入数据,输出夹角的大小精确到小数点后两位。
Sample Input
2
1 1 2 2
1 1 1 0
Sample Output
0.00
45.00
Source
Basic Problem

#include<stdio.h>#include<cmath>int main(){    int t;    double x1,x2,y1,y2;    while(~scanf("%d",&t))    {        while(t--)        {            scanf("%lf%lf%lf%lf",&x1,&y1,&x2,&y2);            double s1=x1*x2+y1*y2;            double s2=sqrt(x1*x1+y1*y1)*sqrt(x2*x2+y2*y2);        //  printf("%lf %lf",s1,s2);            printf ("%.2lf\n",acos(s1/s2)/3.1415926*180.0);        }    }    return 0;}
原创粉丝点击