Original link:
http://www.cnblogs.com/xiaoxiao075/p/10267119.html
# To find the saddle point of a multidimensional array, that is, the position of elements on the maximum and minimum in the column on the line, it may not have a saddle point List1 = [ [2,4,6,7], [1,3,5,8], [4,6,7,9]] row_maxlist=[] column_minlist=[] for i in range(len(list1)): max_row=max(list1[i]) print('max_row:',max_row) for j in range(len(list1[i])): if list1[i][j]==max_row: row_maxlist.append((i,j)) # Two-dimensional permutation bit list, find the minimum value of each column by the same method; and a recording (J, I) List2 = [] for J in Range (len (List1 [0])): temp=[] for i in range(len(list1)): temp.append(list1[i][j]) list2.append(temp) print(list2) for i in range(len(list2)): min_row=min(list2[i]) for j in range(len(list2[i])): if list2[i][j]==min_row: column_minlist.append ((j, i)) # # and then recording (j, i) print('row_maxlist',row_maxlist) print('column_minlist',column_minlist) result=set(row_maxlist)&set(column_minlist) ##求交集 print(result)
Reproduced in: https: //www.cnblogs.com/xiaoxiao075/p/10267119.html