Advertisement
Guest User

maxim

a guest
Feb 21st, 2017
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.55 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3. unsigned n,i,j=0;
  4. int a[30],maxim;
  5. void divide(unsigned s,unsigned d,unsigned &m)
  6. {
  7. m=(s+d)/2;
  8. }
  9. void combina(float x,float y,float &z)
  10. {
  11. if(x>y){
  12. z=x;
  13. }
  14. else{
  15. z=y;
  16. }
  17. }
  18. void dei(unsigned s, unsigned d,float &z)
  19. {
  20. unsigned m;
  21. float x1,x2;
  22. if(d==s)
  23. {
  24.  
  25. z=a[s];
  26.  
  27. }
  28. else
  29. {
  30. divide(s,d,m);
  31. dei(s,m,x1);
  32. dei(m+1,d,x2);
  33. combina(x1,x2,z);
  34. }
  35. }
  36. int main ()
  37. {
  38. float z;
  39. cout<<"n= ";
  40. cin>>n;
  41. for(i=1;i<=n;i++){
  42. cout<<"a["<<i<<"]= ";
  43. cin>>a[i];}
  44.  
  45. dei(1,n,z);
  46. cout<<"max="<<z;
  47.  
  48.  
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement