第4章-21 判断上三角矩阵
通过观察发现只要满足数组中,所在行大于所在列的数是0就行了:
T = int(input()) for i in range(T): a = [] flag = 0 n = int(input()) for j in range(n): s = input() a.append([int(n) for n in s.split()]) for j in range(n): for k in range(n): if j > k: if a[j][k] != 0: flag = 1 if flag == 0: print('Yes') else: print('No')