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