| |
|
|
p.specht
| Und otra vez una Rosettacode-Tarea en XProfan übertragen: Man lugar una N * N Schachbrett así voller Dame-Figuren, dass esta se no gegenseitig bedrohen.
Título de la ventana "N-Queens Problema (de 11x11 viel Geduld nötig!)"
'https://rosettacode.org/wiki/N-queens_problem#BBC_BASIC
Ventana de Estilo 24
declarar sl$,i%,j%,tmp%,co%,num%,Size%,Cell%
Proc Brett
font 1
declarar i&
whileloop Size%+4:i&=&Loop:whileloop Size%+4
if between(i&,3,Size%+2) and between(&Loop,3,Size%+2)
imprimir if((i&+&Loop) mod 2," ",chr$(176));
más :imprimir "+";:endif:endwhile:imprimir
Endwhile
ENDPROC
Nochma:
CLS:font 2
imprimir "\n Schachbrett-Breite = ";
input sl$
caso val(sl$)<4:sl$=8
Cls
Size%=val(sl$)
Cell%=32
Brett
locate Size%+6,3:Imprimir " Rechnet ...";
num%=FNqueens(Size%,Cell%)
locate Size%+6,3
font 2
imprimir " Für ein",size%," x ",size%,"Brett hay total "+STR$(num%)+" Lösungen!"
beep
WaitInput
Goto "Nochma"
Proc FNqueens :parámetros n%,s%
declarar i%,j%,m%,p%,q%,r%,a%[n%],b%[n%],c%[4*n%-2]
:whileloop n%:i%=&Loop:a%[i%]=i%:endwhile
m%=0
i%=1
j%=0
r%=2*n%-1
REPEAT
dec i%
inc j%
p%=0
q%= -r%
REPEAT
inc i%
c%[p%]=1
c%[q%+r%]=1
tmp%=a%[i%]:a%[i%]=a%[j%]:a%[j%]=tmp%
p%=i%-a%[i%]+n%
q%=i%+a%[i%]-1
b%[i%]=j%
j%=i%+1
UNTIL (j%>n%) O c%[p%] O c%[q%+r%]
IF c%[p%]=0
IF c%[q%+r%]=0
IF m%=0'.te Solución darstellen, =m% ... todos
Whileloop n%:p%=&Loop
LOCATE a%[p%]+2,p%+2
PRINT "D";
Endwhile
ENDIF
inc m%
ENDIF
ENDIF
j%=b%[i%]
WHILE (j%>=n%) AND (i%<>0)
REPEAT
tmp%=a%[i%]:a%[i%]=a%[j%]:a%[j%]=tmp%
j%=j%-1
UNTIL j%<i%
dec i%
p%=i%-a%[i%]+n%
q%=i%+a%[i%]-1
j%=b%[i%]
c%[p%]=0
c%[q%+r%]=0
ENDWHILE
UNTIL i%=0
Volver m%
ENDPROC
|
|
|
| XProfan 11Computer: Gerät, daß es in Mikrosekunden erlaubt, 50.000 Fehler zu machen, zB 'daß' statt 'das'... | 29.05.2021 ▲ |
|
|
|