-2

# Why ? Sorry my bad english

Input: 8 4 6 4 3 12 18 9 11 Output: 4 6 3 1212 18 ( i want 3 12 18) 9 11 https://code.sololearn.com/cHdJCNi9kpxU/?ref=app

1/5/2020 12:57:45 PM

Tài Nguyễn.G

0

3 < 12 so you print 3 12 and 12 < 18 so you also print 12 18 and there is no space behind "3 12" and no space before "12 18" If you dont want to print it twice you need to increase i by an additional 1 in the if clause i < i +1

+1

No i < i +1 is always true i just didnt want to write the whole clause: i ment in the clause a[i] < a[i +1] you also need to increase i by 1 with i++

+1

Cause when you have 2 4 6 with your code you would print 2 44 6 but you want 2 4 6: So you need to increase i by 2 in total after printing 2 4 cause if you only increse it by 1 in the next iteration i = 1 and a[1] = 4 and a[2] = 6 and 4 < 6 so you would print 4 6 which results in printing 4 twice

+1

But if you do it my way you also need to print a[i] instead of a[i +1] in the else body cause you already increased i by 1

0

Thank you, you mean If (a[i] <a[i+1] && i<i+1 ) right ?