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