diff --git a/sorting/Bubble_Sort_2.c b/sorting/Bubble_Sort_2.c index f11fd63e..c141ba91 100644 --- a/sorting/Bubble_Sort_2.c +++ b/sorting/Bubble_Sort_2.c @@ -1,56 +1,47 @@ #include #include -#define MAX 20 +#define MAX 20 #define TRUE 1 #define FALSE 0 - int main() { - int i , arraySort[MAX] ={0} , isSort = FALSE, changePlace; - - - /* For example + int i, arraySort[MAX] = {0}, isSort = FALSE, changePlace; + + /* For example Insertion random values in array to test */ - - - for(i = 0 ; i < MAX; i++) + + for (i = 0; i < MAX; i++) { - arraySort[i] = rand()%101 ; + arraySort[i] = rand() % 101; } - -/* Algorithm of bubble methods */ - - while(isSort) + /* Algorithm of bubble methods */ + + while (isSort) { - isSort = FALSE; + 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; - } - - } + for (i = 0; i < MAX - 1; i++) + { + if (arraySort[i] > arraySort[i + 1]) + { + changePlace = arraySort[i]; + arraySort[i] = arraySort[i + 1]; + arraySort[i + 1] = changePlace; + isSort = TRUE; + } + } } /* See if it works */ - - for(i = 0 ; i < MAX; i++) + + for (i = 0; i < MAX; i++) { - printf("%d\n", arraySort[i]); + printf("%d\n", arraySort[i]); } - - - return EXIT_SUCCESS; - }