Advertisement
Guest User

Untitled

a guest
Dec 8th, 2019
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.85 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <math.h>
  3.  
  4.  
  5.  
  6.  
  7. void cilindr(double s, double v, double *pr, double *ph);
  8. int main(void)
  9.  
  10. {
  11. double r,h, r1=0,h1=0, s, v, k;
  12.  
  13. scanf("%lf",&r);
  14.  
  15. scanf("%lf",&h);
  16. cilindr(r,h, &s, &v);
  17. /* printf("ploshad=%lf, obem=%lf",s,v ); */
  18. k=1000000.;
  19. for (r=1.;r<=50.;++r);
  20. s=2*M_PI*r*(r+h);
  21.  
  22.  
  23.  
  24. if (fabs((r/(2*(r+h))-1)<fabs(k-1))
  25. { k=(r/(2*(r+h)));
  26. r1=r;
  27. h1=h;
  28. }
  29.  
  30. }
  31. }
  32. printf("%.0lf\n", r1);
  33. printf("%.0lf", h1 );
  34. return 0;
  35. }
  36.  
  37. void cilindr(double x, double y, double *ps , double *pv)
  38. {
  39. *ps=2*M_PI*x*(x+y);
  40. *pv=M_PI*y*pow(x,2);
  41.  
  42.  
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement