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. {
  12. struct Triangle t;
  13. double p;
  14. double s;
  15.  
  16. scanf("%lf", &t.a);
  17. scanf("%lf", &t.b);
  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: %.0lf\n", t.a);
  26. printf("b: %.0lf\n", t.b);
  27. printf("c: %.0lf\n", t.c);
  28. printf("三角形の面積: %f\n", s);
  29.  
  30. return 0;
  31. }
  32.  
Success #stdin #stdout 0.01s 5324KB
stdin
5  5  5
stdout
a: 5
b: 5
c: 5
三角形の面積: 10.825318