python的n皇后

global count
count=0
q=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]
def place(i,j):
    if(i==1): return True
    k=1
    while(kn):
        global count
        count=count+1
        return
    else:
        for j in range(1,n+1):
            if(place(i,j)):
                q[i]=j
                queen(i+1,n)
def main():
    n=eval(input(""));
    queen(1,n);
    print(count)
main()

你可能感兴趣的:(python,python)