0
Need some explanation on my code here
The purpose of this code is to sort the values of the array in ascending/ descending order. I'm having trouble with the multiple for loop part, that I can't wrap my head around it for days. https://code.sololearn.com/cKT6JZ1Ya7nI/?ref=app Also is there another way of writing the loops?
4 Respostas
+ 1
Take a look:
https://code.sololearn.com/cw832D0LA8z5/?ref=app
+ 1
check this:
https://code.sololearn.com/c3vYWBVJfbOI/#cpp
+ 1
Your code is almost correct..but due to some logical errors it doesn't work..
First thing you have to use curly braces for if else statements unless it has only one line of code...
Eg
if(condition)
//One line statement (correct)
if(condition)
// Some part
//Some part
This will not give syntax error but if condition is false then first line won't execute..(try it)
And about logical errors, try thinking about it or understand it by drawing or writing, how it works on paper..
Hint:- check conditions in both loops..
Try tracing your code on paper and you will know where you are wrong..
0
This is definitely something that I had never seen!
I'll do my best understanding the code you wrote. Also thanks for taking the time to help me it means a lot.