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,s;
  12. struct triangle v;
  13. scanf("%lf",&v.a);
  14. scanf("%lf",&v.b);
  15. scanf("%lf",&v.c);
  16. printf("a:%lf\n",v.a);
  17. printf("b:%lf\n",v.b);
  18. printf("c:%lf\n",v.c);
  19. p=(v.a+v.b+v.c)/2;
  20. s=sqrt(p*(p-v.a)*(p-v.b)*(p-v.c));
  21. if(s==0){
  22. printf("その三角形は存在しません。");
  23. }else{
  24. printf("三角形の面積:%lf",s);
  25. return 0;
  26. }
  27. }
  28.  
Success #stdin #stdout 0.01s 5312KB
stdin
5
5
5
stdout
a:5.000000
b:5.000000
c:5.000000
三角形の面積:10.825318