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