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