C Custom Bubble Sort - C++ - Programmation
Marsh Posté le 20-07-2022 à 14:43:11
Hello !
The swap should not be done if the two values are equal, only if "array[i] < array[i++]" because if they are equal, swapping is useless and leads directly to an infinite loop.
By the way, shouldn't there be spaces in the scanf first parameter ?
Regards !
Marsh Posté le 22-07-2022 à 11:25:12
Hello, you are on a french forum so you have to write in french.
Thank you.
Marsh Posté le 20-07-2022 à 13:05:01
I'm attempting to figure out what's wrong with my code; I'm new to C but have a lot of experience with Java. I created my own "lazy" bubble sort implementation using 8 integers. However, it results in an indefinite loop. I read several articles about Bubble sort in C, https://www.scaler.com/topics/c-bubble-sort/.
Attempting to sort 8 integers from greatest to smallest and using the counter to detect when all values are sorted.