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