|
本帖最后由 molucule 于 2022-3-17 00:25 编辑
hp 39&40gs的八皇后程序,结果写在矩阵里:
8->N:
MAKELIST(0,B,1,N,1)->L1:
MAKEMAT(0,1,N)->M1:
0->S:
1->K:
1->J:
1->F:
0->L1(1):
WHILE K>0 REPEAT
L1(K)+1->L1(K):
WHILE L1(K)<=N REPEAT
1->J:
1->F:
WHILE J<K AND F==1 REPEAT
IF(L1(J)==L1(K) OR ABS(L1(J)-L1(K))==ABS(J-K)) THEN
0->F:
END:
J+1->J:
END:
IF F==1 THEN
BREAK:
END:
L1(K)+1->L1(K):
END:
IF L1(K)<=N THEN
IF K==N THEN
S+1->S:
DISP 4;S:
L1->M2:
ADDROW M1;M2;1:
ELSE
K+1->K:
0->L1(K):
END:
ELSE
K-1->K:
END:
END:
DELROW M1;S+1:
|
|