fork download
  1. #include <stdio.h>
  2. #include <math.h>
  3. struct triangle{
  4. double a,b,c;
  5. };
  6. int main(void){
  7. struct triangle t={5,5,5};
  8. double h,S;
  9. h = (t.a + t.b + t.c) / 2.0;
  10. S = sqrt(h * (h - t.a) * (h - t.b) * (h - t.c));
  11.  
  12. printf("a: %g\n", t.a);
  13. printf("b: %g\n", t.b);
  14. printf("c: %g\n", t.c);
  15. printf("三角形の面積: %f\n", S);
  16.  
  17. return 0;
  18. }
  19.  
Success #stdin #stdout 0.01s 5320KB
stdin
Standard input is empty
stdout
a: 5
b: 5
c: 5
三角形の面積: 10.825318