View Code of Problem 24

#include<stdio.h>
#include<string.h>
#include<math.h>
#include<algorithm>
using namespace std;

int main() {
//S=√[p(p-a)(p-b)(p-c)]
//p为半周长:p=(a+b+c)/2
	int a,b,c;
	while(scanf("%d %d %d",&a,&b,&c)!=EOF) {
		double sum;
		double p=(double)(a+b+c)/2.0;
//		printf("%lf\n",p);
		sum=sqrt(p*(p-a)*(p-b)*(p-c));
		printf("%.2lf\n",sum);
	}
}

Double click to view unformatted code.


Back to problem 24