View Code of Problem 24

#include<stdio.h>
#include<math.h>
void main(){
	int a,b,c;
	double h,cosA,s;
	scanf("%d%d%d",&a,&b,&c);
	if(a+b>c&&a+c>b&&b+c>a){
		cosA=(b*b+c*c-a*a)/(2.0*b*c);
		h=sqrt(b*b-b*cosA*b*cosA);
		s=0.5*c*h;
		printf("%.2f\n",s);
	}
	else
		printf("error!\n");
}

Double click to view unformatted code.


Back to problem 24