#include <stdio.h>
#include <math.h>
// 三角形の構造体を定義
typedef struct {
double a; // 1つ目の辺の長さ
double b; // 2つ目の辺の長さ
double c; // 3つ目の辺の長さ
double area; // 三角形の面積
} Triangle;
int main(void) {
// 三角形の構造体を宣言
Triangle myTriangle;
// 辺の長さを設定
myTriangle.a = 5.0;
myTriangle.b = 5.0;
myTriangle.c = 5.0;
// 半周の計算
double s = (myTriangle.a + myTriangle.b + myTriangle.c) / 2.0;
// ヘロンの公式で面積を計算
myTriangle.
area = sqrt(s
* (s
- myTriangle.
a) * (s
- myTriangle.
b) * (s
- myTriangle.
c));
// 結果の出力
printf("a : %lf\n", myTriangle.
a); printf("b : %lf\n", myTriangle.
b); printf("c : %lf\n", myTriangle.
c); printf("三角形の面積 : %lf\n", myTriangle.
area);
return 0;
}
I2luY2x1ZGUgPHN0ZGlvLmg+CiNpbmNsdWRlIDxtYXRoLmg+CgovLyDkuInop5LlvaLjga7mp4vpgKDkvZPjgpLlrprnvqkKdHlwZWRlZiBzdHJ1Y3QgewogICAgZG91YmxlIGE7ICAvLyAx44Gk55uu44Gu6L6644Gu6ZW344GVCiAgICBkb3VibGUgYjsgIC8vIDLjgaTnm67jga7ovrrjga7plbfjgZUKICAgIGRvdWJsZSBjOyAgLy8gM+OBpOebruOBrui+uuOBrumVt+OBlQogICAgZG91YmxlIGFyZWE7ICAvLyDkuInop5LlvaLjga7pnaLnqY0KfSBUcmlhbmdsZTsKCmludCBtYWluKHZvaWQpIHsKICAgIC8vIOS4ieinkuW9ouOBruani+mAoOS9k+OCkuWuo+iogAogICAgVHJpYW5nbGUgbXlUcmlhbmdsZTsKICAgIAogICAgLy8g6L6644Gu6ZW344GV44KS6Kit5a6aCiAgICBteVRyaWFuZ2xlLmEgPSA1LjA7CiAgICBteVRyaWFuZ2xlLmIgPSA1LjA7CiAgICBteVRyaWFuZ2xlLmMgPSA1LjA7CiAgICAKICAgIC8vIOWNiuWRqOOBruioiOeulwogICAgZG91YmxlIHMgPSAobXlUcm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