c语言程序设计 输入三角形的3条边a,b,c,如果能构成三角形,输入面积crea和周长preimeter(保留两位小数)

c语言程序设计 输入三角形的3条边a,b,c,如果能构成三角形,输入面积crea和周长preimeter(保留两位小数)
其他人气:894 ℃时间:2020-04-14 13:52:42
优质解答
#include
#include
void main(void)
{
double a, b, c, S, p;
int TRUE = 0;
printf("Enter three numbers for sides of a triangle: ");
scanf("%lf %lf %lf", &a, &b, &c);
if((a + b > c) && (b + c > a) && (c + a > b))
{
TRUE = 1;
p = (a + b + c) / 2;
S = sqrt(p * (p - a) * (p - b) * (p - c));
}
if(TRUE == 1)
{
printf("\nThese three sides can structure a triangle.\n");
printf("The area of the triangle is %.2f.\n", S);
printf("The perimeter of the triangle is %.2f.\n", 2 * p);
}
}
我来回答
类似推荐
请使用1024x768 IE6.0或更高版本浏览器浏览本站点,以保证最佳阅读效果。本页提供作业小助手,一起搜作业以及作业好帮手最新版!
版权所有 CopyRight © 2012-2024 作业小助手 All Rights Reserved. 手机版