标签:
from numpy import * def safe(row,col,qipan): for i in range(0,row): if qipan[i] == col or abs(qipan[i] - col) == abs(row - i): return False return True def eightQue(row,col,qipan): qipan1 = qipan if row == 8: print(qipan1) else: for j in range(8): if safe(row,j,qipan1): qipan1[row] = j eightQue(row+1,col,qipan1) qipan = [0,0,0,0,0,0,0,0] eightQue(0,7,qipan)
标签:
原文地址:http://my.oschina.net/stevenKelly/blog/396298