weixin_45673373 2019-09-22 17:26 采纳率: 0%
浏览 1695

warning C4244: 'argument' : conversion from 'double' to 'float', possible loss of data 具体问题在哪里呢?怎么改

#include
#include
int main(void){
float x1,y1,x2,y2,x3,y3;
float p,a,b,c,S;
printf("input three coordinates to calculate the area of the triangle:");
scanf("%f%f%f%f%f%f",&x1,&y1,&x2,&y2,&x3,&y3);
a=sqrtf((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
b=sqrtf((x1-x3)*(x1-x3)+(y1-y3)*(y1-y3));
c=sqrtf((x2-x3)*(x2-x3)+(y2-y3)*(y2-y3));
if(a>b)
{t=a;a=b;b=t;}
if(a>c)
{t=a;a=c;c=t;}
if(b>c)
{t=b;b=c;c=t;}
if(c=a+b)
{printf("These three line segments can't be combined to be a triangle")}
else if(c>a+b)
{ p=(a+b+c)/(2.0);
S=sqrtf(p*(p-a)*(p-b)*(p-c));
printf("The area of the triangle is:%.2f",S);
}

return 0;

}

  • 写回答

1条回答 默认 最新

  • threenewbee 2019-09-22 17:28
    关注

    float x1,y1,x2,y2,x3,y3;
    float p,a,b,c,S;

    ->

    double x1,y1,x2,y2,x3,y3;
    double p,a,b,c,S;

    scanf("%f%f%f%f%f%f",&x1,&y1,&x2,&y2,&x3,&y3);
    ->
    scanf("%lf%lf%lf%lf%lf%lf",&x1,&y1,&x2,&y2,&x3,&y3);

    评论

报告相同问题?

悬赏问题

  • ¥15 对于相关问题的求解与代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料
  • ¥15 使用R语言marginaleffects包进行边际效应图绘制
  • ¥20 usb设备兼容性问题
  • ¥15 错误(10048): “调用exui内部功能”库命令的参数“参数4”不能接受空数据。怎么解决啊
  • ¥15 安装svn网络有问题怎么办