本文主要是介绍uva 10522 - Height to Area(几何),希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
题目链接:uva 10522 - Height to Area
海伦公式。
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>using namespace std;
const double eps = 1e-9;int main () {int N, C = 0;double a, b, c;scanf("%d", &N);while (N) {scanf("%lf%lf%lf", &a, &b, &c);if (fabs(a) < eps || fabs(b) < eps || fabs(c) < eps) {N--;printf("These are invalid inputs!\n");continue;}a = 1 / a, b = 1 / b, c = 1 / c;double t = a + b + c;double S = t * (t - 2 * a) * (t - 2 * b) * (t - 2 * c);if (S < 0) {N--;printf("These are invalid inputs!\n");continue;}printf("%.3lf\n", 1 / sqrt(S));}return 0;
}
这篇关于uva 10522 - Height to Area(几何)的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!