当前位置: 首页 > 工具软件 > Jsmtpd > 使用案例 >

实验三-2-2、 输入三角形的3条边a、b、c,判断它们能否构成三角形。若能构成三角形,求出三角形面积,若不能,输出“不能构成三角形”。(三角形面积area=sqrt(s*(s-a)*(s-b)*(s

臧令
2023-12-01

#include<stdio.h>
#include<math.h>
int main()
{
float a,b,c,s,area;
printf(“Please input a b and c:\n”);
scanf("%f%f%f",&a,&b,&c);
if(a+b<=c || b+c<=a || a+c<=b)
printf(“a b and c cannot form a triangle.\n”);
else
{
s=(a+b+c)/2;
area=sqrt(s*(s-a)(s-b)(s-c));
printf(“The area of the triangle is %7.2f.\n”,area);
}
return 0;
}

问题:在s=(a+b+c)/2.0上没有带“.0”,发现例题上有带。

解决方案:经过试验后发现好像并不影响。(想请问老师带不带.0是什么区别)

 类似资料: