Rotate the matrix in 90 degrees

 m=int(input("number of rows"))

n=int(input("number of coulmns"))

a=[]

for i in range(m):

    a.append([int(j) for j in input().split()])  

    

for j in range(n):

    for i in range(m-1,-1,-1):

        print(a[i][j],end=" ")

    print()


Input:

number of rows3

number of coulns4

1 2 3 4

5 6 7 8

10 11 12 13


Output:

10 5 1 

11 6 2 

12 7 3 

13 8 4 

No comments:

Post a Comment