fork download
  1. #include <stdio.h>
  2. #include <math.h>
  3.  
  4.  
  5. struct Triangle {
  6. double a;
  7. double b;
  8. double c;
  9. };
  10.  
  11. int main(void) {
  12. struct Triangle tri;
  13. double p,s;
  14.  
  15.  
  16. scanf("%lf", &tri.a);
  17. scanf("%lf", &tri.b);
  18. scanf("%lf", &tri.c);
  19.  
  20.  
  21. p = (tri.a + tri.b + tri.c) / 2.0;
  22.  
  23. s = sqrt(p* (p - tri.a) * (p - tri.b) * (p - tri.c));
  24.  
  25. printf("三角形の面積 : %f\n", s);
  26.  
  27. return 0;
  28. }
Success #stdin #stdout 0s 5288KB
stdin
4 4 4
stdout
三角形の面積 : 6.928203