fork download
  1. #include <stdio.h>
  2. #include <math.h>
  3.  
  4. typedef struct {
  5. double a;
  6. double b;
  7. double c;
  8. } atai;
  9.  
  10. double menseki(atai t) {
  11. double p=(t.a+t.b+t.c)/2.0;
  12. return sqrt(p*(p-t.a)*(p-t.b)*(p-t.c));
  13. }
  14.  
  15. int main(void) {
  16. atai t;
  17. double s;
  18.  
  19. t.a=5;
  20. t.b=5;
  21. t.c=5;
  22.  
  23. s=menseki(t);
  24.  
  25. printf("a : %.0f\n", t.a);
  26. printf("b : %.0f\n", t.b);
  27. printf("c : %.0f\n", t.c);
  28. printf("三角形の面積 : %f\n", s);
  29.  
  30. return 0;
  31. }
  32.  
Success #stdin #stdout 0s 5320KB
stdin
Standard input is empty
stdout
a : 5
b : 5
c : 5
三角形の面積 : 10.825318