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. int main(void) {
  10. struct Triangle tri;
  11. double p, s;
  12.  
  13.  
  14. scanf("%lf", &tri.a);
  15.  
  16. scanf("%lf", &tri.b);
  17.  
  18. scanf("%lf", &tri.c);
  19.  
  20. p = (tri.a + tri.b + tri.c) / 2.0;
  21. s = sqrt(p * (p - tri.a) * (p - tri.b) * (p - tri.c));
  22.  
  23. printf("a : %g\n", tri.a);
  24. printf("b : %g\n", tri.b);
  25. printf("c : %g\n", tri.c);
  26. printf("三角形の面積 : %f\n", s);
  27.  
  28. return 0;
  29. }
Success #stdin #stdout 0s 5292KB
stdin
5
5
5
stdout
a : 5
b : 5
c : 5
三角形の面積 : 10.825318