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 0right
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 0left
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 0left
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.
0left.
compute leftband=leftband/card compute rightband=rightband*card
1left.
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
0right.
compute leftband=leftband*card compute rightband=rightband/card
1right.
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.
¤ Dauer der Verarbeitung: 0.17 Sekunden
(vorverarbeitet)
¤
|
Haftungshinweis
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.
|