Python 实现求矩阵的伴随矩阵
程序员文章站
2022-06-15 17:14:05
...
def remove_line(index,arr):
yy=[]
for i in range(len(arr)):
hh=[]
for j in range(len(arr)):
if(i==index[0] or j==index[1]):
pass
else:
hh.append(arr[i][j])
if(hh!=[]):
yy.append(hh)
# yy.remove([])
return yy
dd=[[0,4,3,5],[2,3,2,6],[3,4,5,7],[3,4,5,7]]
for i in range(len(dd)):
for j in range(len(dd)):
tm_list=remove_line(tuple([i,j]),dd)
print((i,j),tm_list)
就是这样