Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- int main()
- {
- const int n=8;
- int v[]= {3,4,20,6,15,2,1,7},max_right;
- max_right=v[n-1];
- for (int i=n-1; i>-1; i--)
- if (max_right>v[i])
- v[i]=max_right;
- else
- max_right=v[i];
- for (int i=0;i<n;i++)
- cout<<v[i]<<' ';
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement