#include <bits/stdc++.h>
using namespace std;
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int n ;
cin >> n ;
int a[n] ;
for(int i = 0 ; i < n ; i++){
cin >> a[i] ;
}
//sort(starting ,ending) ;
sort(a+2 , a+8) ;
for(int i = 0 ; i < n ; i++){
cout << a[i] <<" " ;
}
}
Input -
8
9 8 7 6 5 4 3 2
Output -
9 8 2 3 4 5 6 7
If we want to sort the full array . We will write the function -
sort(a,a+n) ;
Input -
8
9 8 7 6 5 4 3 2
Output -
2 3 4 5 6 7 8 9
This is ascending order sort .
To sort in descending order we will write -
`sort(a,a+n,greater<int>()) ;
`
Input -
10
9 8 7 6 5 4 3 2 2 1
Output -
9 8 7 6 5 4 3 2 2 1
Top comments (0)