Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- int mx(int a[],int l, int r)
- {
- int m = 0;
- for(int i = l ; i <= r ; i++)
- {
- if( a[i] > m)
- m = a[i];
- }
- return m;
- }
- int main()
- {
- int t ;
- cin >> t;
- while(t--)
- {
- int n ,p = 0;
- cin >> n;
- int a[n];
- for(int i = 0; i < n ; i++)
- {
- cin >> a[i];
- }
- for(int i = 0 ; i < n ; i++)
- {
- for(int j = i ; j < n ; j++ )
- {
- p = mx(a,i,j);
- if(p)
- cout << p << " ";
- }
- }
- cout << endl;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment