/*  3.4 求两点之间的距离,(x1,x2) (y1,y2) 。类似于例3.9 */

#include "stdio.h"
#include "math.h"
void main()
{
    float x1,y1,x2,y2;
    double distance;
    printf("请输入两点(x1,x2) (y1,y2)\n输入示例: 1 1 2 2 即指(1,1)(2,2)\n");
    scanf("%f%f%f%f",&x1,&y1,&x2,&y2);
    distance = sqrt((x2 - x1) * (x2 - x1)+(y2-y1)*(y2-y1));
    printf("两点(%f,%f) (%f,%f)之间的距离为%lf\n",x1,y1,x2,y2,distance);
}

 /*  3.5 摄氏华氏温度转换。 类似于例3.9 */

#include "stdio.h"
#include "math.h"
void main()
{
    float C,F,K;
    printf("请输入摄氏温度\n输入示例25.0 即指25.0摄氏度\n");
    scanf("%f",&C);
    F=9.0/5.0*C+32;
    K=273.16+C;
    printf("华氏温度为%.1f,绝对温度为%.1f\n",F,K);
}
 

 

 

相关文章:

  • 2021-05-24
  • 2021-05-27
  • 2021-05-15
  • 2022-01-09
  • 2022-03-04
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-05-23
  • 2021-12-16
  • 2022-02-06
  • 2021-06-06
  • 2021-11-28
  • 2021-05-15
相关资源
相似解决方案