View Code of Problem 24

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

Double click to view unformatted code.


Back to problem 24