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);

    评论

报告相同问题?

悬赏问题

  • ¥20 ML307A在使用AT命令连接EMQX平台的MQTT时被拒绝
  • ¥20 腾讯企业邮箱邮件可以恢复么
  • ¥15 有人知道怎么将自己的迁移策略布到edgecloudsim上使用吗?
  • ¥15 错误 LNK2001 无法解析的外部符号
  • ¥50 安装pyaudiokits失败
  • ¥15 计组这些题应该咋做呀
  • ¥60 更换迈创SOL6M4AE卡的时候,驱动要重新装才能使用,怎么解决?
  • ¥15 让node服务器有自动加载文件的功能
  • ¥15 jmeter脚本回放有的是对的有的是错的
  • ¥15 r语言蛋白组学相关问题