Sort digits of number
C / C++ / MFC
3
Posts
3
Posters
0
Views
1
Watching
-
How to sort digits of a number?. Can we use bubble sort? If so, how to use values inside for loop?
-
How to sort digits of a number?. Can we use bubble sort? If so, how to use values inside for loop?
Quote:
How to sort digits of a number?
There are several way to do that. A simple approach could be convert the number to a string and then sort the string characters.
Quote:
Can we use bubble sort?
Of course. Anyway, you know, bubble sort is inefficient. However that strongly depends on the size of the input (in your case, I assume the size of the input very small).
Quote:
If so, how to use values inside for loop? Quote Selected Text
What do you mean?
-
How to sort digits of a number?. Can we use bubble sort? If so, how to use values inside for loop?