new code | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

new code

I'm working on my first code with c++, I want to make a code the allow you to orders numbers in sequences, but in different orders for example [4,10,11,15,17] [4,10,11,28,53] [4,10,15,38,53,] [4,10,19,27,49] [4,10,28,56,57] [4,10,32,56,57 and so on, any ideas.

23rd Aug 2019, 11:05 PM
KYLE XY
KYLE XY  - avatar
4 Answers
+ 2
Given an array of numbers, one way is to use two for loops to iterate through the array by comparing consecutive numbers in each iteration and swapping them if needed to move the larger one to the 'right'.
24th Aug 2019, 1:24 AM
Sonic
Sonic - avatar
+ 1
your sequence somehow loses numbers and gains new numbers seemingly at random... (i see no pattern) you would have to explain the process more...😅
24th Aug 2019, 12:39 AM
Anton Böhler
Anton Böhler - avatar
0
@Anton Böhler no problem the sequences is not easy but I think is poseable if see the numbers repeat but at one point it starts to changes for example 4,10,11 in the first line and then on the second line is the same 4,10,11 but on the third line the numbers start again with 4,10 and it changes and so on. [4,10,11,15,17] [4,10,11,28,53] [4,10,15,38,53,] [4,10,19,27,49] [4,10,28,56,57] [4,10,32,56,57
24th Aug 2019, 1:27 AM
KYLE XY
KYLE XY  - avatar
0
@Sonic can you take a look at the code because I have no idea how an array work or look I'm new at c++. I'm learning how it works
24th Aug 2019, 1:52 AM
KYLE XY
KYLE XY  - avatar