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