You are given an integer 51234
(say) we need to sort the digits of a number the output will be 12345
.
How to do it without using array ?
General overview:
The only potentially tricky bit might be properly handling zeros - you don't want too many, and you'll want to handle the edge case where the input is zero properly.
Actual implementation is left as an exercise...
You don't need to write a program at all, just do it with shell commands:
echo "51234" | sed 's+\(.\)+\1\n+g' | sort | tr -d '\n'
Create a container interface over the int (something like vector), where operator references the i'th decimal digit. You would have to define iterators and other things too. Then call std::sort on it. ;)