mirror of
https://github.com/TheAlgorithms/C
synced 2024-11-28 16:23:10 +03:00
Merge pull request #6 from malnuxstarck/patch-1
Add a other way to sort array with bubble Method
This commit is contained in:
commit
7b302b48cd
35
OtherBubbleSort.c
Normal file
35
OtherBubbleSort.c
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
#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;
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
return EXIT_SUCCESS;
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user