fork download
  1. #include <stdio.h>
  2. #include <math.h>
  3.  
  4. struct triangle{
  5. int a;
  6. int b;
  7. int c;
  8. };
  9.  
  10. int main(void){
  11. double p,s;
  12. struct triangle v;
  13. scanf("%d",&v.a);
  14. scanf("%d",&v.b);
  15. scanf("%d",&v.c);
  16. printf("a:%d\n",v.a);
  17. printf("b:%d\n",v.b);
  18. printf("c:%d\n",v.c);
  19. p=(v.a+v.b+v.c)/2;
  20. printf("ba:%d\n",p-v.a);
  21. printf("bb:%d\n",p-v.b);
  22. printf("bc:%d\n",p-v.c);
  23. s=sqrt(p*(p-v.a)*(p-v.b)*(p-v.c));
  24. if(s==0){
  25. printf("その三角形は存在しません。");
  26. }else{
  27. printf("三角形の面積:%lf",s);
  28. return 0;
  29. }
  30. }
  31.  
Success #stdin #stdout 0s 5288KB
stdin
5
4
2
stdout
a:5
b:4
c:2
ba:5
bb:0
bc:0
その三角形は存在しません。