Sorting elements | Sololearn: Learn to code for FREE!

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

11/13/2018 8:27:59 AM

mo🐼

5 Answers

New Answer

+3

Then start sorting from 1

+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++) {

+1

Then skip in 2s for (i=1; i<(n-1); i+=2) { "swap a[i], a[i+1] " }

0

yes I tried that 5 m ago after a lot of disasters but thank you

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 🙆