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. int main(void) {
  10. struct triangle d;
  11. scanf("%lf %lf %lf",&d.a,&d.b,&d.c);
  12.  
  13. double p,s;
  14.  
  15. p = (d.a+d.b+d.c)/2.0;
  16. s = sqrt(p*(p-d.a)*(p-d.b)*(p-d.c));
  17. printf("a:%lf\n",d.a);
  18. printf("b:%lf\n",d.b);
  19. printf("c:%lf\n",d.c);
  20. printf("三角形の面積:%lf",s);
  21. return 0;
  22. }
  23.  
  24.  
  25.  
Success #stdin #stdout 0s 5308KB
stdin
5 5 5
stdout
a:5.000000
b:5.000000
c:5.000000
三角形の面積:10.825318