0
Sorting numbers of an array as we put in the numbers
Hey guys! How can I sort the numbers of an array and print them at the same time as the user puts in the numbers from stdin?
4 Respuestas
+ 1
HonFu thank you very much!!
+ 1
HonFu thank you I did it!
0
You could do that for example by inserting the value exactly at the right spot the moment it is given.
That could go like this:
With a loop you find the spot where for the first time a number is larger than the input.
You move every element from here one to the right (backwards from the end in order not to overwrite anything, and the last value 'drops out' if it's a fixed-size array).
Finally you insert the value at the initially determined spot.
0
Now the trouble and fun of implementing it begins - good luck! :)