update old main function

This commit is contained in:
northernSage 2021-02-17 07:15:47 -03:00
parent 9ba58f4571
commit 366724b585

View File

@ -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;
}