编程介的小学生 2019-08-08 22:13 采纳率: 20.5%
浏览 730

C语言,求两个点分别和原点的连线的夹角的大小

Problem Description
这次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

  • 写回答

1条回答 默认 最新

  • 锦之龙 2019-08-09 11:27
    关注

    #include “stdio.h” /* printf /
    #include “math.h” /
    atan */
    #define PI 3.14159265
    int main ()
    {
    double x1, y1, x2, y2;
    double alh1, alh2, result;
    printf("Please input the first dot.\n");
    scanf("%f %f", &x1, &y1);
    printf("Please input the second dot.\n");
    scanf("%f %f", &x2, &y2);
    alh1 = atan (y1/x1) * 180 / PI; //将弧度转换为度
    alh2 = atan (y2/x2) * 180 / PI; //将弧度转换为度
    result = abs(alh2 - alh1);
    printf ("The angle1 of two line is %f degrees.\n", result );
    return 0;
    }

    评论

报告相同问题?

悬赏问题

  • ¥15 delta降尺度计算的一些细节,有偿
  • ¥15 Arduino红外遥控代码有问题
  • ¥15 数值计算离散正交多项式
  • ¥30 数值计算均差系数编程
  • ¥15 redis-full-check比较 两个集群的数据出错
  • ¥15 Matlab编程问题
  • ¥15 训练的多模态特征融合模型准确度很低怎么办
  • ¥15 kylin启动报错log4j类冲突
  • ¥15 超声波模块测距控制点灯,灯的闪烁很不稳定,经过调试发现测的距离偏大
  • ¥15 import arcpy出现importing _arcgisscripting 找不到相关程序