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 x;
  12. double d, s;
  13.  
  14. x.a = 5;
  15. x.b = 5;
  16. x.c = 5;
  17.  
  18. d = (x.a + x.b + x.c) / 2.0;
  19.  
  20. s = sqrt(d * (d - x.a) * (d - x.b) * (d - x.c));
  21.  
  22. printf("a:%d\n", (int)x.a);
  23. printf("b:%d\n", (int)x.b);
  24. printf("c:%d\n", (int)x.c);
  25. printf("三角形の面積:%f\n", s);
  26.  
  27. return 0;
  28. }
Success #stdin #stdout 0.01s 5308KB
stdin
Standard input is empty
stdout
a:5
b:5
c:5
三角形の面積:10.825318