import numpy as np
def lcs(i, j):
global x, y, c
if i <= 0 or j <= 0:
return 0
else:
if c[i][j] < 0:
if x[i - 1] == y[j - 1]:
c[i][j] = lcs(i - 1, j - 1) + 1
else:
m = lcs(i - 1, j)
n = lcs(i, j - 1)
print m, n
c[i][j] = max(m, n)
else: return c[i][j]
c = np.zeros((8, 8), int)
c = c - 1
x = 'ABCBDAB'
y = 'BDCABA'
lcs(7, 6)
print c
该程序有错误,所以我查找'm','n',
打印结果为“无”
前任:
0 0
0 None
0 None
0 None
None None
然后程序出现错误:
TypeError: long() argument must be a string or a number, not 'NoneType'
我不知道“无”来自哪里
我是新人,谢谢