Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- unsigned n,i,j=0;
- int a[30],maxim;
- void divide(unsigned s,unsigned d,unsigned &m)
- {
- m=(s+d)/2;
- }
- void combina(float x,float y,float &z)
- {
- if(x>y){
- z=x;
- }
- else{
- z=y;
- }
- }
- void dei(unsigned s, unsigned d,float &z)
- {
- unsigned m;
- float x1,x2;
- if(d==s)
- {
- z=a[s];
- }
- else
- {
- divide(s,d,m);
- dei(s,m,x1);
- dei(m+1,d,x2);
- combina(x1,x2,z);
- }
- }
- int main ()
- {
- float z;
- cout<<"n= ";
- cin>>n;
- for(i=1;i<=n;i++){
- cout<<"a["<<i<<"]= ";
- cin>>a[i];}
- dei(1,n,z);
- cout<<"max="<<z;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement