mirror of
https://github.moeyy.xyz/https://github.com/TheAlgorithms/C.git
synced 2023-10-11 15:56:24 +08:00
update old main function
This commit is contained in:
parent
9ba58f4571
commit
366724b585
@ -64,43 +64,12 @@ static void test() {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Main function
|
||||
* @returns 0 on exit
|
||||
*/
|
||||
int main()
|
||||
{
|
||||
int i, array_sort[MAX] = {0}, is_sorted = false, change_place;
|
||||
|
||||
/* For example
|
||||
Insertion random values in array to test
|
||||
*/
|
||||
|
||||
for (i = 0; i < MAX; i++)
|
||||
{
|
||||
array_sort[i] = rand() % 101;
|
||||
}
|
||||
|
||||
/* Algorithm of bubble methods */
|
||||
|
||||
while (is_sorted)
|
||||
{
|
||||
is_sorted = false;
|
||||
|
||||
for (i = 0; i < MAX - 1; i++)
|
||||
{
|
||||
if (array_sort[i] > array_sort[i + 1])
|
||||
{
|
||||
change_place = array_sort[i];
|
||||
array_sort[i] = array_sort[i + 1];
|
||||
array_sort[i + 1] = change_place;
|
||||
is_sorted = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* See if it works */
|
||||
|
||||
for (i = 0; i < MAX; i++)
|
||||
{
|
||||
printf("%d\n", array_sort[i]);
|
||||
}
|
||||
|
||||
test(); // call test routine
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user