Skip to content

Commit

Permalink
Merge pull request TheAlgorithms#18 from theycallmemac/patch-7
Browse files Browse the repository at this point in the history
Rename OtherBubbleSort.c to Sorts/OtherBubbleSort.c
  • Loading branch information
r0hit-gupta authored Aug 8, 2017
2 parents fd9b1c4 + 0d29db3 commit d357a45
Showing 1 changed file with 56 additions and 0 deletions.
56 changes: 56 additions & 0 deletions Sorts/OtherBubbleSort.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
#include <stdio.h>
#include <stdlib.h>
#define MAX 20
#define TRUE 1
#define FALSE 0


int main()
{

int i , arraySort[MAX] ={0} , isSort = FALSE, changePlace;


/* For example
Insertion random values in array to test
*/


for(i = 0 ; i < MAX; i++)
{
arraySort[i] = rand()%101 ;
}


/* Algorithm of bubble methods */

while(isSort)
{
isSort = FALSE;

for( i = 0 ; i < MAX - 1 ; i++)
{
if(arraySort[i] > arraySort[i+1])
{
changePlace = arratSort[i];
arraySort[i] = arraySort[i+1];
arraySort[i+1] = changePlace ;
isSort = TRUE;
}

}
}

/* See if it works */

for(i = 0 ; i < MAX; i++)
{
printf("%d\n", arraySort[i]);
}




return EXIT_SUCCESS;

}

0 comments on commit d357a45

Please sign in to comment.