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