identification division .
program-id . turing.
author . "JD" .
date-written . 25 .10 .2004 .
date-compiled .
data division .
working-storage section .
77 card pic 9 (4 ) value 5 .
77 leftband pic 9 (16 ) value 0 .
77 state pic 9 (16 ).
88 startstate value 0 .
77 endstate pic 9 (16 ).
88 value 3 .
77 head pic 9 (1 ).
linkage section .
77 rightband pic 9 (16 ).
procedure division using reference rightband.
**********************************************
*simuliert eine Turing Maschine
* Bandalphabet als Integer mit Kardinalität card
* Eingbealphabet als Integer mit Kardinalität card
* rechtes Band als Integer mit Basis card(Alphabet)
* linkes Band als Integer mit Basis card(Alphabet)
* Zustand als Integer
**********************************************
display "start"
* check rightband for input alphabet obmitted
set startstate to true
perform until (state=endstate)
compute head=function mod(rightband,card)
evaluate true
when state=0
if head=0 then move 1 to state perform xright
end-if
when state=1
if head=0 then move 1 to state perform 0 right
else if head=1 then move 2 to state perform yleft
else if head=2 then continue
else if head=3 then continue
else if head=4 then move 1 to state perform yright
when state=2
if head=0 then move 4 to state perform 0 left
else if head=1 then continue
else if head=2 then continue
else if head=3 then move 3 to state perform xright
else if head=4 then move 2 to state perform yleft
when state=3
if head=0 then continue
else if head=1 then continue
else if head=2 then move 5 to state perform yright
else if head=3 then continue
else if head=4 then move 3 to state perform yright
when state=4
if head=0 then move 4 to state perform 0 left
else if head=1 then continue
else if head=2 then continue
else if head=3 then move 0 to state perform xright
else if head=4 then continue
when state=endstate
display "ende, Leftband=" leftband" Rightband=" rightband
end-evaluate
end-perform .
goback .
0 left .
compute leftband=leftband/card compute rightband=rightband*card
1 left .
compute leftband=leftband/card compute rightband=rightband*card+1
bleft.
compute leftband=leftband/card compute rightband=rightband*card+2
xleft.
compute leftband=leftband/card compute rightband=rightband*card+3
yleft.
compute leftband=leftband/card compute rightband=rightband*card+4
0 right .
compute leftband=leftband*card compute rightband=rightband/card
1 right .
compute leftband=leftband*card compute rightband=rightband/card+1
bright.
compute leftband=leftband*card compute rightband=rightband/card+2
xright.
compute leftband=leftband*card compute rightband=rightband/card+3
yright.
compute leftband=leftband*card compute rightband=rightband/card+4
end-program turing.
Messung V0.5 in Prozent C=90 H=100 G=95
¤ Dauer der Verarbeitung: 0.12 Sekunden
(vorverarbeitet am 2026-06-07)
¤
*© Formatika GbR, Deutschland