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:
Modular DIY Geiger–Müller counterThe Geiger–Müller counter is a relatively simple tool to measure ionizing radiation. To increase sensitivity, construction presented here contains thr… Read More
Collecting data from measurements devices using USBTMC, SCPI, Python and R High end test gear allows two-way communication with PC to set measurement parameters and to send the measured data to PC for further analyze. On PC s… Read More
8 Best Programming SongsCode monkey Written by Jonathan Coulton, link to the lyric. I love this song, maybe because I'v worked a lot of time in different corporations :) … Read More
How does recursive packing of a file changes its size?How the size of a packed file will change if you will pack it again? How will it change if you do that again and again? Will it be the same, bigger of… Read More
How to use finite state machine in parsing of assembly language?Finite State Machine - abstract Often data must be analyzed chunk by chunk, checked if all of those chunks are valid (if the chunk is valid itself an… 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