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