This program sorts in descending order.
Hey guys, I am wondering if I could get some help with making this bubble sort program
sort recursively. Any help would be appreciated, thanks.
#include <stdio.h>
#include <conio.h>
#include <iostream>
#include <stdlib>
#define TRUE 1
#define FALSE 0
void bubble (int[], int);
void Swap(int &, int &);
void main() // The main is used every time but slight modifications to function bubble
{
const int size = 5;
int arry[size] = {10, 9, 5, 1, 8};
bubble (arry, size);
for (int i = 0; i < size; i++)
cout<<arry[i]<<" ";
//printf(" ",&arry[i]);
getch();
} //End of main
void Swap(int &a, int &b)
{
int hold;
hold = a;
a = b;
b = hold;
}
void bubble( int x[], int n )
{
int j, pass;
int switched = TRUE;
for( pass = 0; pass < n - 1 && switched == TRUE; pass++ )
{
switched = FALSE;
for( j = 0; j < n - pass - 1; j++ )
{
if( x[j] < x[j+1] )
{
switched = TRUE;
Swap(x[j], x[j+1]);
}
}
}
}