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