custom output coming true but all test cases showing wrong (arrays -wave problem)
Custom output coming true but all test cases showing wrong (arrays -wave problem)
@myself.yash.srivastav
Please share your code using ide.codingblocks.com so I can have a look at your code.
can you tell me whats wrong ?
@myself.yash.srivastav
Your code incorrect answers in case when m and n are not equal
Input :
4 5
11 12 13 14 15
21 22 23 24 25
31 32 33 34 35
41 42 43 44 45
Expected Output :
11, 21, 31, 41, 42, 32, 22, 12, 13, 23, 33, 43, 44, 34, 24, 14, 15, 25, 35, 45, END
Your Output :
11, 21, 31, 41, 835732896, 32764, 42, 32, 22, 12, 13, 23, 33, 43, 4196042, 0, 44, 34, 24, 14, 15, 25, 35, 45, 0, END
This is because you used n as your loop control variable for both i and j loops and have forgot to use m at all. Use m for no of rows or your code will access invalid memory locations giving you wrong answers.
Thank you, its resolved now.