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?

10th Apr 2019, 8:06 PM
MargaritaK
4 Respuestas
+ 1
HonFu thank you very much!!
10th Apr 2019, 8:19 PM
MargaritaK
+ 1
HonFu thank you I did it!
10th Apr 2019, 8:43 PM
MargaritaK
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.
10th Apr 2019, 8:16 PM
HonFu
HonFu - avatar
0
Now the trouble and fun of implementing it begins - good luck! :)
10th Apr 2019, 8:20 PM
HonFu
HonFu - avatar