#include <stdio.h>
#include <stdlib.h>
#include <math.h>
int main(int argc, char *argv[]) {
	float a,b,c,area,s;
	//input
	printf("please input the three sides of triangle:\n");
	scanf("%f%f%f",&a,&b,&c);
	//calculate
	s=(a+b+c)/2;
    if(s*(s-a)*(s-b)*(s-c)<=0){
    printf("Three side entered do not represent the sides of a triangle\n");
    }
    else{
	area=sqrt(s*(s-a)*(s-b)*(s-c));
	//output
	printf("The area of this triangle is %5.2f\n",area);
    }
    system("pause");
	return 0;
}

更多推荐

C语言海伦公式计算三角形面积