how to rotate a matrix 90 degrees clockwise
int n=A.size(); for(int i=0;i<n/2;i++){ for(int j=i;j<n-i-1;j++){ int temp=A[i][j]; A[i][j]=A[n-1-j][i]; A[n-1-j][i]=A[n-1-i][n-1-j]; A[n-1-i][n-1-j]=A[j][n-1-i]; A[j][n-1-i]=temp; } }
rotate matrix 90 degrees clockwise in python
#The program defines the square matrix 90 degrees clockwise direction. m,n = map(int,input().split()) #m,n are the number of rows and columns. #m = int(input('rows')) l = [] for i in range(m): x = list(map(int,input().split())) #for taking the rows a time and split it append to an empty list l.append() for i in range(m): for j in range(m-1,-1,-1): print(l[j][i],end=' ') print(end='\n')