Hello
Just want to ask how can i use my function now in the main ... after i put the numbers for example i want them to be sorted in ascending or descending order
PHP Code:
# include <iostream>
using namespace std;
int main () {
int array [10];
cout << " enter numbers : ";
for ( int i=0; i<10; i++)
cin >> array[i];
cout << " the numbers after sort : "<<bubblesort();
}
void bubblesort ( int list[], int length ) {
int step , index , temp;
for ( step =1; step<length; step++)
{
for ( index=0; index<length-step; index++)
if ( list [index] == list [ index+1 ])
temp = list [ index];
list [index] = list[index+1];
list[index+1] = temp;
}
}




Reply With Quote