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