Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int v[100];
- int max(int i,int j)
- {
- int a,b,m;
- if(i==j) return v[i];
- else
- {
- m = (i+j)/2;
- a=max(i,m);
- b=max(m+1,j);
- if(a>b) return a;
- else return b;
- }
- }
- int main()
- {
- int n,i;
- cout<<"n=";cin>>n;
- for(i=0;i<n;i++)
- {
- cout<<"v["<<i<<"]=";
- cin>>v[i];
- }
- cout<<"Maximul este "<<max(1,n);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement