You get 10 numbers on STDIN, each followed by newline character, after that you have to display those numbers sorted from the smaller to the bigger. You cannot use sorting algorithms.
Subscribe to:
Post Comments (Atom)
in programming, riddle / with 5 comments /
You get 10 numbers on STDIN, each followed by newline character, after that you have to display those numbers sorted from the smaller to the bigger. You cannot use sorting algorithms.
If you will use any algoritm to show them sorted, that algorythm might be called "sorting algorythm" and become illegal to use ;)
ReplyDeleteHi Alex,
ReplyDeletesure, you're right :)
I will precise this in that way: you can't use sort algorithms on data structure, that you are using to keep numbers after receiving them all from user.
What about storing them into the tree? ;) will the "left/root\right" way of extracting numbers from tree be treating as sorting algorithm then? ;)
ReplyDeleteI think, that it wouldn't be sorting :P
ReplyDeleteThere is plenty ways to do that, e.g. store new number in list in ordered way. This could be also done by storing numbers in array and then display smallest number and indicate in other array, that this element won't be displayed in next iteration. This would be repeated for all numbers in array.
i see :)
ReplyDelete