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