mirror of
https://github.moeyy.xyz/https://github.com/TheAlgorithms/C.git
synced 2023-10-11 15:56:24 +08:00
code cleanup & fixed syntax error
This commit is contained in:
parent
a3989bbadc
commit
cee2468506
@ -4,53 +4,44 @@
|
||||
#define TRUE 1
|
||||
#define FALSE 0
|
||||
|
||||
|
||||
int main()
|
||||
{
|
||||
|
||||
int i , arraySort[MAX] ={0} , isSort = FALSE, changePlace;
|
||||
|
||||
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 */
|
||||
|
||||
/* Algorithm of bubble methods */
|
||||
|
||||
while(isSort)
|
||||
while (isSort)
|
||||
{
|
||||
isSort = FALSE;
|
||||
|
||||
for( i = 0 ; i < MAX - 1 ; i++)
|
||||
for (i = 0; i < MAX - 1; i++)
|
||||
{
|
||||
if(arraySort[i] > arraySort[i+1])
|
||||
if (arraySort[i] > arraySort[i + 1])
|
||||
{
|
||||
changePlace = arratSort[i];
|
||||
arraySort[i] = arraySort[i+1];
|
||||
arraySort[i+1] = changePlace ;
|
||||
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]);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user