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.
How to sort numbers from STDIN
in programming, riddle / with 5 comments /
Related Posts:
Conway's Game of Life - online JavaScript versionGame of life is an example of a system with very simple rules but unpredictable state in the long term. Each square represents a living space availab… Read More
How to check how many elements an enum has?While C language doesn't offer build in method to check how many elements an enum has, it's still possible to obtain this information by using a simpl… Read More
Fractal way of map generation by using diamond-square algorithmDiamond-square algorithm is a simple way to generate maps by using fractal approach. The idea is to generate recursively a point based on the values o… Read More
How to check how many elements an array has?In C it's possible to omit typing array size if it's fields are provided immediately, so the compiler can easily calculate the size by itself. This is… Read More
Julia set, Cantor set and Fern fractal implemented in JavScript .fractalWindow { background: #e0e0e0; padding: 0; margin: auto; display: block; margin-top: 20px; margin-bottom: 20px; } .drawFr… Read More
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