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个回答

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

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问