#include <stdio.h>
#include <math.h>
// Triangle構造体の定義
struct Triangle {
double a;
double b;
double c;
};
// 三角形の面積をヘロンの公式で計算する関数
double calculate_area(struct Triangle t) {
double s = (t.a + t.b + t.c) / 2; // 半周長
return sqrt(s
* (s
- t.
a) * (s
- t.
b) * (s
- t.
c)); // 面積を計算 }
int main(void) {
struct Triangle t;
// ユーザから3辺の長さを入力
// 面積を計算
double area = calculate_area(t);
// 結果を表示
printf("三角形の面積は: %.2f\n", area
);
return 0;
}
I2luY2x1ZGUgPHN0ZGlvLmg+CiNpbmNsdWRlIDxtYXRoLmg+CgovLyBUcmlhbmdsZeani+mAoOS9k+OBruWumue+qQpzdHJ1Y3QgVHJpYW5nbGUgewogICAgZG91YmxlIGE7CiAgICBkb3VibGUgYjsKICAgIGRvdWJsZSBjOwp9OwoKLy8g5LiJ6KeS5b2i44Gu6Z2i56mN44KS44OY44Ot44Oz44Gu5YWs5byP44Gn6KiI566X44GZ44KL6Zai5pWwCmRvdWJsZSBjYWxjdWxhdGVfYXJlYShzdHJ1Y3QgVHJpYW5nbGUgdCkgewogICAgZG91YmxlIHMgPSAodC5hICsgdC5iICsgdC5jKSAvIDI7ICAvLyDljYrlkajplbcKICAgIHJldHVybiBzcXJ0KHMgKiAocyAtIHQuYSkgKiAocyAtIHQuYikgKiAocyAtIHQuYykpOyAgLy8g6Z2i56mN44KS6KiI566XCn0KCmludCBtYWluKHZvaWQpIHsKICAgIHN0cnVjdCBUcmlhbmdsZSB0OwoKICAgIC8vIOODpuODvOOCtuOBi+OCiTPovrrjga7plbfjgZXjgpLlhaXlipsKICAgIHByaW50ZigiYTogIik7CiAgICBzY2FuZigiJWxmIiwgJnQuYSk7CiAgICBwcmludGYoImI6ICIpOwogICAgc2NhbmYoIiVsZiIsICZ0LmIpOwogICAgcHJpbnRmKCJjOiAiKTsKICAgIHNjYW5mKCIlbGYiLCAmdC5jKTsKCiAgICAvLyDpnaLnqY3jgpLoqIjnrpcKICAgIGRvdWJsZSBhcmVhID0gY2FsY3VsYXRlX2FyZWEodCk7CgogICAgLy8g57WQ5p6c44KS6KGo56S6CiAgICBwcmludGYoIuS4ieinkuW9ouOBrumdouepjeOBrzogJS4yZlxuIiwgYXJlYSk7CgogICAgcmV0dXJuIDA7Cn0K