fork(1) 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. printf("辺 a: ");
  14. scanf("%lf", &triangle.a);
  15. printf("辺 b: ");
  16. scanf("%lf", &triangle.b);
  17. printf("辺 c: ");
  18. scanf("%lf", &triangle.c);
  19.  
  20. double s = (triangle.a + triangle.b + triangle.c) / 2.0;
  21. double area = sqrt(s * (s - triangle.a) * (s - triangle.b) * (s - triangle.c));
  22.  
  23. printf("\n三角形の辺: a = %.2lf, b = %.2lf, c = %.2lf\n", triangle.a, triangle.b, triangle.c);
  24. printf("三角形の面積: %.2lf\n", area);
  25.  
  26. return 0;
  27. }
Success #stdin #stdout 0s 5288KB
stdin
Standard input is empty
stdout
辺 a: 辺 b: 辺 c: 
三角形の辺: a = 0.00, b = 0.00, c = 0.00
三角形の面積: 0.00