4 1 7 4 1 4 8 3 6 1 6 1 2 0 7 8 9 2 1 2 1 7 4 1 NONE1 # 找鞍点 2 # Author: cnRick 3 # Time : 2020-3-30 4 n = int(input()) 5 matrix = [] 6 isNone = True 7 for i in range(n): #构建矩阵 8 thisLine = list(map(int,input().split())) 9 matrix.append(thisLine) 10 for row in range(n): 11 for col in range(n): 12 thisNum = matrix[row][col] 13 isRowMax = True 14 isColMin = True 15 for i in range(n): 16 if thisNum < matrix[row][i]: 17 isRowMax = False 18 break 19 if isRowMax == True: 20 for i in range(n): 21 if thisNum > matrix[i][col]: 22 isColMin = False 23 break 24 if isRowMax == True and isColMin == True: 25 isNone = False 26 print("{:d} {:d}".format(row,col)) 27 else: 28 if isNone == True: 29 print("NONE") 30
原文:https://www.cnblogs.com/dreamcoding/p/12599449.html