0

Help me

given a rectangular matrix. Move the negative elements of even lines to the left without changing their order. Example: 1 -7 -3 5 -10 1-3 4 -6 -2 -6 3 -1 -3 7 -3 -4 1 3 -7 -6 2 -1 8 4 After sorting: 1 -7 -3 5 -10 -3 -6 -2 1 4 -6 3 -1 -3 7 -3 -4 -7 1 3 -6 2 -1 8 4

20th Mar 2018, 8:52 AM
Ден Демянчук
Ден Демянчук - avatar
2 Answers
+ 13
run a loop for moving through all rows of the matrix , if rowIndex%2==1 , then run a loop for replacing posn of -ve elemeny with +ve element ... ie if 2 , -1 ...then make it -1 ,2 , this will not even disturb the order . //edit : no code , thats the way I suggested //true learner must give a try by himself first .
20th Mar 2018, 9:59 AM
Gaurav Agrawal
Gaurav Agrawal - avatar
0
Could you please sample the code?
20th Mar 2018, 10:15 AM
Ден Демянчук
Ден Демянчук - avatar