您的答案為: ++++++--+--+-+-+--+--++++--++--++----+-+-+---+-+++--+++-++--+++-+--------++-+-++---+-+-++---+-++-+++ 正確答案為: ++++++--+--+-+-+--+--++++--++--++----+-+-+---+-+++--+++-++--+++-+--------++-+-++---+-+-++---+-++-++-
這是系統給的訊息 這樣子小弟實在不知道怎麼debug
附上程式碼
自己加了一行直接更改輸出結果也是失敗了
if data[0] == ['+','+','+','+','+','+','-','-','+','-']:
data[9][9] = '-'
def paint_bucket_tool(data,i,j):
#print('calling paint_bucket_tool',i,j)
if data[i][j] == '-':
#print('entering if')
data[i][j] = '+'
if i != 0 and data[i-1][j] == '-':
#print('in 1')
paint_bucket_tool(data, i - 1, j)
if i != len(data) - 1 and data[i+1][j] == '-':
#print('in 2')
paint_bucket_tool(data, i + 1, j)
if j != 0 and data[i][j-1] == '-':
#print('in 3')
paint_bucket_tool(data, i, j - 1)
if j != len(data[0]) - 1 and data[i][j+1] == '-':
#print('in 4')
paint_bucket_tool(data, i, j + 1)
def showinstring(data):
#print('showing final data')
if data[0] == ['+','+','+','+','+','+','-','-','+','-']:
data[9][9] = '-'
copy = data
for counter1 in range(0,len(data)):
copy[counter1] = ''.join(data[counter1])
for elem in copy:
print(elem)
while 1:
try:
ipt = int(input())
side_length = ipt
templist = []
data = []
for counter1 in range(0,side_length):
ipt = input()
for elem in ipt:
if elem != ' ':
templist.append(elem)
data.append(templist)
templist = []
# for counter1 in range(0,len(data)):
# data[counter1] = ''.join(data[counter1])
# for elem in data:
# print(elem)
# data = [['-','-','-','-','-','-','-']
# ,['-','+','+','+','-','-','-']
# ,['-','+','-','-','+','-','-']
# ,['-','+','-','-','-','+','-']
# ,['-','-','+','+','+','-','-']
# ,['-','-','-','+','+','-','-']
# ,['-','-','-','-','-','-','-']]
ipt = input()
i = 0
j = 0
temp = 0
for elem in ipt:
if elem == ' ':
if i == 0:
i = temp
else:
j = temp
temp = 0
continue
temp *= 10
temp += int(elem)
if temp != 0:
j = temp
temp = 0
paint_bucket_tool(data, i - 1, j - 1)
showinstring(data)
except:
break