Skip to content

Instantly share code, notes, and snippets.

@uysalserkan
Last active January 20, 2019 13:33
Show Gist options
  • Save uysalserkan/01f90ced5055efd4fb2e8da38e7588f6 to your computer and use it in GitHub Desktop.
Save uysalserkan/01f90ced5055efd4fb2e8da38e7588f6 to your computer and use it in GitHub Desktop.
#include <iostream>
#define SIZE 10
void bubblesorting(int a[SIZE]);
using namespace std;
int main(void) {
int usr[SIZE]={0},i=0;
cout << '\t'<<"Welcome" << endl<<"Please enter 10 number for sorting: ";
for(i=0;i<SIZE;i++){
cin >>usr[i];
}
//sorting step.
bubblesorting(usr);
for(i=0;i<SIZE;i++)
cout <<usr[i]<<" ";
cout <<endl;
}
void bubblesorting(int a[SIZE]){
int i,j,temp;
for(j=0;j<SIZE;j++){
for(i=0;i<SIZE-1;i++){
if(a[i]>a[i+1]){
temp=a[i];
a[i]=a[i+1];
a[i+1]=temp;
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment