Advertisement
Guest User

Untitled

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