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

stdout
a : 5
b : 5
c : 5
三角形の面積: 10.825318