For some inputs, The code is working for others it is failing. I am unable to find out the reason.
Explanation for code:
My approach is to find out the diagonal element first (m,m). For eg, 3,4 will lie in the column of 4,4 and 6,5 will lie in the row of of 6,6 and so on.
After that using the bool variable (col), I find out if the required element lies in the same column or the same row.
col_inc is used to find if the values are increasing in the column or decreasing in the column ( starting from row 0) and vice versa for row.
After this I just print the values using the formulas - ele -/+ (m -x/y).
Can you please help me find out my mistake? (I know this is very complex approach to a simple solution but I want to know where I made a mistake)
Thank you in advance.