fork download
  1. #include <stdio.h>
  2. #include <math.h>
  3.  
  4. /* 三角形の構造体 */
  5. struct Triangle {
  6. double a, b, c;
  7. };
  8.  
  9. int main(void) {
  10. struct Triangle t;
  11. double p, s;
  12.  
  13. /* 入力 */
  14. scanf("%lf %lf %lf", &t.a, &t.b, &t.c);
  15.  
  16. /* 面積計算(ヘロンの公式) */
  17. p = (t.a + t.b + t.c) / 2;
  18. s = sqrt(p * (p - t.a) * (p - t.b) * (p - t.c));
  19.  
  20. /* 出力 */
  21. printf("a:%g\n", t.a);
  22. printf("b:%g\n", t.b);
  23. printf("c:%g\n", t.c);
  24. printf("三角形の面積:%lf\n", s);
  25.  
  26. return 0;
  27. }
  28.  
  29.  
  30.  
Success #stdin #stdout 0s 5320KB
stdin
5
5
5
stdout
a:5
b:5
c:5
三角形の面積:10.825318