from Common import inputMatrix def searchSortedMatrix(matrix, item): x, y = len(matrix[0]) - 1, 0 while x >= 0 and y < len(matrix): curr = matrix[x][y] if curr == item: print('Item present at [{}, {}]'.format(x, y)) return elif curr < item: y += 1 elif curr > item: x -= 1 print('Item not found') matrix = inputMatrix() item = int(input('Enter search item: ')) searchSortedMatrix(matrix, item)
from Common import inputMatrix arr = inputMatrix() m = len(arr) n = len(arr[0]) res = [[0 for i in range(m)] for j in range(n)] for i in range(n): for j in range(m): res[i][j] = arr[j][i] for i in range(n): for j in range(m): print(res[i][j], end=' ') print()