#include <iostream>
#include <vector>
void sort(std::vector<int> &arr, int n, int j){
if(n==1){
return;
}
if(arr[j]<arr[j+1]){
int tmp = arr[j];
arr[j] = arr[j+1];
arr[j+1] = tmp;
}
sort(arr, n-1, j+1);
}
int main() {
std::vector<int> arr = {9,2,7,4};
int n = arr.size();
sort(arr, n, 0);
for(int i=0; i<n; i++){
std::cout<<arr[i]<<' ';
}
}
To embed this project on your website, copy the following code and paste it into your website's HTML: