#include <stdio.h>
#include <math.h>
// 三角形の辺を定義する構造体
typedef struct {
double a;
double b;
double c;
} Triangle;
// 三角形の面積を計算する関数
double calculate_area(Triangle t) {
double s = (t.a + t.b + t.c) / 2.0;
return sqrt(s
* (s
- t.
a) * (s
- t.
b) * (s
- t.
c)); }
int main(void) {
Triangle triangle;
double area;
// ユーザー入力
scanf("%lf", &triangle.
a); scanf("%lf", &triangle.
b); scanf("%lf", &triangle.
c);
// 妥当性チェック
if (triangle.a + triangle.b <= triangle.c ||
triangle.a + triangle.c <= triangle.b ||
triangle.b + triangle.c <= triangle.a) {
return 1; // 異常終了
}
// 面積を計算
area = calculate_area(triangle);
// 結果を出力
printf("a:%.0f\n", triangle.
a); printf("b:%.0f\n", triangle.
b); printf("c:%.0f\n", triangle.
c); printf("三角形の面積:%.6lf\n", area
);
return 0;
}
I2luY2x1ZGUgPHN0ZGlvLmg+CiNpbmNsdWRlIDxtYXRoLmg+CgovLyDkuInop5LlvaLjga7ovrrjgpLlrprnvqnjgZnjgovmp4vpgKDkvZMKdHlwZWRlZiBzdHJ1Y3QgewogICAgZG91YmxlIGE7CiAgICBkb3VibGUgYjsKICAgIGRvdWJsZSBjOwp9IFRyaWFuZ2xlOwoKLy8g5LiJ6KeS5b2i44Gu6Z2i56mN44KS6KiI566X44GZ44KL6Zai5pWwCmRvdWJsZSBjYWxjdWxhdGVfYXJlYShUcmlhbmdsZSB0KSB7CiAgICBkb3VibGUgcyA9ICh0LmEgKyB0LmIgKyB0LmMpIC8gMi4wOwogICAgcmV0dXJuIHNxcnQocyAqIChzIC0gdC5hKSAqIChzIC0gdC5iKSAqIChzIC0gdC5jKSk7Cn0KCmludCBtYWluKHZvaWQpIHsKICAgIFRyaWFuZ2xlIHRyaWFuZ2xlOwogICAgZG91YmxlIGFyZWE7CgogICAgLy8g44Om44O844K244O85YWl5YqbCiAgICBwcmludGYoIuS4ieinkuW9ouOBrui+uuOCkuWFpeWKm+OBl+OBpuOBj+OBoOOBleOBhOOAgl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