#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);
// 面積を計算
area = calculate_area(triangle);
// 結果を出力
printf("a: %.2lf\n", triangle.
a); printf("b: %.2lf\n", triangle.
b); printf("c: %.2lf\n", triangle.
c); printf("三角形の面積: %.6lf\n", area
);
return 0;
}
I2luY2x1ZGUgPHN0ZGlvLmg+CiNpbmNsdWRlIDxtYXRoLmg+CgovLyDkuInop5LlvaLjga7ovrrjgpLlrprnvqnjgZnjgovmp4vpgKDkvZMKdHlwZWRlZiBzdHJ1Y3QgewogICAgZG91YmxlIGE7CiAgICBkb3VibGUgYjsKICAgIGRvdWJsZSBjOwp9IFRyaWFuZ2xlOwoKLy8g5LiJ6KeS5b2i44Gu6Z2i56mN44KS6KiI566X44GZ44KL6Zai5pWwCmRvdWJsZSBjYWxjdWxhdGVfYXJlYShUcmlhbmdsZSB0KSB7CiAgICAvLyDljYrlkajplbfjgpLoqIjnrpcKICAgIGRvdWJsZSBzID0gKHQuYSArIHQuYiArIHQuYykgLyAyLjA7CiAgICAvLyDjg5jjg63jg7Pjga7lhazlvI8KICAgIHJldHVybiBzcXJ0KHMgKiAocyAtIHQuYSkgKiAocyAtIHQuYikgKiAocyAtIHQuYykpOwp9CgppbnQgbWFpbih2b2lkKSB7CiAgICBUcmlhbmdsZSB0cmlhbmdsZTsKICAgIGRvdWJsZSBhcmVhOwoKICAgIC8vIOODpuODvOOCtuODvOWFpeWKmwogICAgcHJpbnRmKCLkuInop5LlvaLjga7ovrrjgpLlhaXlipvjgZfjgabjgY/jgaDjgZXjgYTjgIJcbi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