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