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