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