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 A={7,8,9};
  12. double s=(A.a+A.b+A.c)/2;
  13. double S=sqrt(s*(s-A.a)*(s-A.b)*(s-A.c));
  14. printf("a = %.1lf\n", A.a);
  15. printf("b = %.1lf\n", A.b);
  16. printf("c = %.1lf\n", A.c);
  17. printf("三角形の面積: S = %.2lf\n", S);
  18.  
  19. return 0;
  20. }
Success #stdin #stdout 0.01s 5284KB
stdin
5
5
5
stdout
a = 7.0
b = 8.0
c = 9.0
三角形の面積: S = 26.83