0
Write c++ program that sort the numbers -11,20,0,6,72,11 in ascending /descending using recursive function pleasr help.
7 Respuestas
+ 2
Misgun Evan
Working. Just make another function for descending order.
Code will be same just condition is changed as I mentioned in previous reply
+ 1
Attempts?
+ 1
Misgun Evan
For descending you can check in opposite:
if (arr[i] < arr[i + 1])
0
#include <iostream>
using namespace std;
void recurbublSort(int arr[], int len){
int temp;
if (len == 1){
return;
}
for (int i=0; i<len-1; i++){
if (arr[i] > arr[i+1]){
temp=arr[i];
arr[i]=arr[i+1];
arr[i+1]=temp;
}
}
len=len-1;
recurbublSort(arr, len);
}
int main(){
int Arr[] = {-11,20,0,6,72,11};
int length = sizeof(Arr)/sizeof(Arr[0]);
recurbublSort(Arr, length);
cout<<"Sorted array : ";
for(int i=0;i<length;i++){
cout<<Arr[i]<<" ";
}
return 0;
}
0
It only works ascending
- 1
It doesn't work please write a full programm tnx
- 1
Ok tnx ❤ please am waiting for your response