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