我正在尝试使用python解决此问题,但是代码无法正常工作,我也不明白为什么。
x=[]
y=[]
J=0
h=int(input("height of matrix"))
w=int(input("width of matrix"))
for i in range (h):
row= input ("row_n (number with pace)").split()
x.append(row)
for j in range(h):
for h in range (w):
if x[j][h]=="1":
J+=1
y.append(J)
print(y)
Haha=y[0]
for z in y:
print (z)
if z != y[0]:
print("this is not a regular graph")
break
else:
print ("this is a regular graph")