bubble_sort

please give me feedback on :)
https://www.facebook.com/invigorating.arslaan

#include "iostream"
#include "stddef.h"
#include <math.h>
using namespace std;


int main( )
{

const int n = 5;
int array[n] = {10,2,1,5,4};

for (int i = 0 ; i < n ; i++){
for (int j = 0 ; j < n-i-1 ; j++){
if(array[j] > array[j+1]){
int temp = array[j];
array[j] = array[j+1];
array[j+1] = temp;
}
}
}

for(int k = 0 ; k <n ; k++){
cout<<array[k]<<endl;
}

return 0;
}

Comments

Popular Posts