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. struct Triangle triangle;
  12.  
  13. scanf("%lf", &triangle.a);
  14. scanf("%lf", &triangle.b);
  15. scanf("%lf", &triangle.c);
  16.  
  17. double s = (triangle.a + triangle.b + triangle.c) / 2.0;
  18. double area = sqrt(s * (s - triangle.a) * (s - triangle.b) * (s - triangle.c));
  19.  
  20. printf("三角形の辺:はa = %.1lf, b = %.1lf, c = %.1lf\n", triangle.a, triangle.b, triangle.c);
  21. printf("三角形の面積は %.6lf\n", area);
  22.  
  23. return 0;
  24. }
  25.  
Success #stdin #stdout 0s 5280KB
stdin
5 5 5
stdout
三角形の辺:はa = 5.0, b = 5.0, c = 5.0
三角形の面積は 10.825318