0

Sorting elements

if I want to sort those elements except the first number I entered like this -4 5 7 -13 -1 ---> -4 -13 -1 5 7 what should I change is that have something to do with a [0]🙆 https://code.sololearn.com/c4r8z7vSOBYh/?ref=app

13th Nov 2018, 8:27 AM
mo🐼
mo🐼 - avatar
5 odpowiedzi
+ 3
Then start sorting from 1
13th Nov 2018, 8:40 AM
Taste
Taste - avatar
+ 1
Is this question solved, then ? If not, change the start of your sorting loop to start with i=1 not i=0: for (i=1; i<(n-1); i++) { for (j=i+1; j<n; j++) {
13th Nov 2018, 2:02 PM
Leif
Leif - avatar
+ 1
Then skip in 2s for (i=1; i<(n-1); i+=2) { "swap a[i], a[i+1] " }
14th Nov 2018, 6:38 AM
Leif
Leif - avatar
0
yes I tried that 5 m ago after a lot of disasters but thank you
13th Nov 2018, 8:44 AM
mo🐼
mo🐼 - avatar
0
yes solved but now a new prob I need to keep the first in his place and change the the others with their neighbours 🙆
13th Nov 2018, 9:13 PM
mo🐼
mo🐼 - avatar