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.  
  13. double x;
  14. double s;
  15.  
  16. scanf("%lf",&t.a);
  17. scanf("%lf",&t.b);
  18. scanf("%lf",&t.c);
  19. x = (t.a + t.b + t.c) / 2.0;
  20.  
  21. s = sqrt(x * (x - t.a) * (x - t.b) * (x - t.c));
  22.  
  23. printf("a : %0.lf\n", t.a);
  24. printf("b : %0.lf\n", t.b);
  25. printf("c : %0.lf\n", t.c);
  26. printf("三角形の面積 : %f\n", s);
  27.  
  28. return 0;
  29. }
  30.  
  31.  
Success #stdin #stdout 0.01s 5284KB
stdin
5
5
5
stdout
a : 5
b : 5
c : 5
三角形の面積 : 10.825318