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