what is the problem in this code for image rotation, it gives wrong answer for both the test cases??
link of the code-- https://ide.codingblocks.com/#/s/13727
Image rotation hacker blocks
In your code, after taking transpose you tried to interchange the first half of the rows with later half. But, actually first half of the columns must be interchanged with second half in same manner as you did (with the rows). Try to do it with columns.
I have exchanged the columns only, the output is correct but it shows wrong answer on hacker blocks.
there is some other mistake, please see
I hope that you are referring to the question that, I give matrix input it rotates it by 90 degrees as:
4 4
1 2 3 4
5 6 7 8
9 10 11 12
13 14 15 16
Expected Output is:
13 9 5 1
14 10 6 2
15 11 7 3
16 12 8 4
But your code produces output as:
4 8 12 16
3 7 11 15
2 6 10 14
1 5 9 13
expected output is supposed to be this and this is the same what my code produces :
4 8 12 16
3 7 11 15
2 6 10 14
1 5 9 13
rotation is to be done LEFT not right
please understand my doubt
this is the link to the question : https://hack.codingblocks.com/contests/c/452/439
Oh ok, my bad.
In your code you tried to input the both ‘r’ and ‘c’ but the test cases provides only one integer for the dimensions as it gives you a square matrix.
thanks! it worked