|
DataMuseum.dkPresents historical artifacts from the history of: RegneCentralen GIER Computer |
This is an automatic "excavation" of a thematic subset of
See our Wiki for more about RegneCentralen GIER Computer Excavated with: AutoArchaeologist - Free & Open Source Software. |
top - download
Length: 38890 (0x97ea) Description: Bits:30000590 GIER DEMON 1D algol3< 770303 Types: 8-hole paper tape Notes: Gier Text, Has10
begin _____[ s t o p ] real procedure skrvml(u); ____ _________value u; integer u; _____ _______begin _____for u:=u step -1 until 1 do writechar(0); ___ ____ _____ __skrvml:=255⨯2∧252∧2; | |end; ___[ s t o p ] comment GIER DEMONSTRATION PROGRAM-1D; _______boolean newnim, newmap, newlineq, newprime, newlanu; _______integer linerest, oldrand, type; _______switch TYPE := NIM, MAP, LINEQ, PRIME, LANU, FINISH; ______procedure NEWPAGE; _________begin _____for linerest := linerest - 1 while linerest _ -9 do writecr; ___ _____ > __linerest := 62end NEWPAGE; ___procedure LINE; _________begin _____linerest := linerest - 1; writecr;if linerest < 0 then NEWPAGE __ ____end LINE; ___procedure SHIFT(n); _________value n; _____integer n; _______if linerest < n then NEWPAGE; __ ____procedure CHECKLINE; _________if char= 64 ∨ char= 192 then __ ____begin _____linerest := linerest - 1; SHIFT(0)end CHECKLINE; ___integer procedure RANDOM(n); _______ _________value n; _____integer n; _______begin _____real y, MOD; ____MOD := 32768; y := oldrand⨯6859; oldrand := y - MOD⨯entier(y/MOD); RANDOM := 1 + entier(n⨯oldrand/MOD)end RANDOM; ___START: oldrand := 999; linerest := 65;newnim := newmap := newlineq := newprime := newlanu := true; ____writechar(62);commen_ - -3- ______DEMON-1D ;writetext(|< <GIER DEMONSTRATION PROGRAM 1D Programmet kan bruges paa 5 forskellige maader: 1. Tændstikspillet: NIM. 2. Trykning af tilfældige landkort. 3. Løsning af tilfældige lineære ligninger. 4. Beregning af primtal. 5. Beregning af store tal. 6 giver program slut.Skriv Deres initialer her:|); >linerest := linerest - 11;begin _____integer i, j, sum; _______sum := type char+ type char;for i := 1 step 1 until sum do j := RANDOM(1) ___ ____ _____ __end of advance of random procedure; ___RESTART: LINE; LINE; SHIFT(10);writetext(|<Vælg program type 1-5 (6 giver program stop): |); < >type := type char; LINE; LINE;go_to TYPE[type]; __ __go_to RESTART; __ __NIM: SHIFT(10);writetext(|<Type 1. Tændstikspillet: NIM|); < >LINE; LINE;begin comment NIM-block; _____ _______boolean longtext, winmessage, wrongmessage, loosemessage, present; _______integer M, G, N, g, n, t, gno, remove, fact, R, boolsum, aritsum, ask, _______GMAX, nmax; longtext := newnim;commen_ - -4- ______DEMON-1D ;if newnim then __ ____begin _____SHIFT(10);writetext(|< <SPILLEREGLER FOR NIM Spillet begynder med et tilfældigt udvalg af G bunker af tændstikker. Hverbunke indeholder højst M tændstikker. M skrives som 2∧N - 1, og De skal opgive |N og G. Vi vil saa skiftevis fjerne tændstikker fra bunkerne. Den, som fjerner den eller de sidste tændstikker, har vundet. Kun een bunke maa røres i hvert træk, og man skal fjerne mindst een tændstik fra den bunke.|); >linerest := linerest - 7end if newnim; ___AGAIN: SHIFT(4); LINE;winmessage := wrongmessage := loose message := false; _____writetext(|<Opgiv N: |); < >N := type in;if N > 9 then N := 9; __ ____LINE; CHECKLINE;M := 2∧N - 1; |ask := 0;writetext(|<Opgiv G: |); < >G := type in;if G > 15 then G := 15; __ ____LINE; CHECKLINE; LINE; LINE;begin comment inner NIM-block; _____ _______integer array GROUP[1:G], SUM[1:N], BITS[1:G, 1:N]; _______ _____procedure PRINTGROUPS; _________for g := 1 step 1 until G do write(|-ndd|, GROUP[g]); ___ ____ _____ __ < >procedure DISPLAY BITS(g); _________value g; _____integer g; _______begin _____R := GROUP[g]; fact := 2;commen_ - -5- ______DEMON-1D ;for n := 1 step 1 until N do ___ ____ _____ __begin _____present := R _ fact⨯fact | R; : =if present then R := R - fact _ 2; __ ____ :BITS[g,n] := if present then 1 else 0; __ ____ ____fact := fact⨯2end for n ___end DISPLAY BITS; ___procedure FIND SUM; _________begin _____aritsum := 0;for g := 1 step 1 until G do aritsum := aritsum + GROUP[g]; ___ ____ _____ __for n := 1 step 1 until N do ___ ____ _____ __begin _____boolsum := 0;for g := 1 step 1 until G do boolsum := boolsum + BITS[g,n]; ___ ____ _____ __SUM[n] := boolsum - boolsum _ 2⨯2 :end; ___boolsum := 0; fact := 1;for n := 1 step 1 until N do ___ ____ _____ __begin _____boolsum := boolsum + SUM[n]⨯fact; fact := 2⨯factend for n ___end FIND SUM; ___for g := 1 step 1 until G do ___ ____ _____ __begin _____GROUP[g] := RANDOM(M); DISPLAY BITS(g)end for g; ___FIND SUM; SHIFT(4);writetext(|<Her er bunkerne:|); < >LINE;writetext(|<Bunke nr.: |); < >for g := 1 step 1 until G do write(|-ndd|, g); ___ ____ _____ __ < >LINE;writetext(|<Antal tændstikker:|); < >PRINTGROUPS; BB: SHIFT(4);commen_ - -6- ______DEMON-1D ;writetext(|< <Hvis De ønsker at gøre det første træk, skriver De et 1-tal her, ellerset 2-tal: |); >linerest := linerest - 2; t := type char;if t | 1 ∧ t | 2 then go_to BB; __ = = ____ __ __if t = 2 then go_to II; __ ____ __ __GG: SHIFT(4); LINE;writetext(if longtext then __ ____|<Skriv her nummeret paa den bunke, fra hvilken De vil fjerne tændstikker: | < >else |<Vælg Deres bunke: |); ____ < >CC: gno := type in; CHECKLINE; LINE;if gno < 1 ∨ gno > G then __ ____begin _____writetext(|<Undskyld, men tallet er for |, if gno < 1 then |<lille.| else |<stort.|); < > __ ____ < > ____ < >DD: LINE;writetext(|< Prøv igen her: |); < >go_to CC __ __end if out of range; ___if GROUP[gno] = 0 then __ ____begin _____writetext(|<Undskyld, men denne bunke er tom.|); < >go_to DD __ __end if empty group; ___remove := GROUP[gno];if remove | 1 then __ = ____begin _____SHIFT(4);writetext(if longtext then __ ____|<Og antallet af tændstikker, De vil fjerne: | else |<Og antallet: |); < > ____ < >EE: remove := type in; CHECKLINE; LINE;commen_ - -7- ______DEMON-1D ;if remove < 1 then __ ____begin _____writetext(|<De skal fjerne mindst een tændstik. Prøv igen: |); < >go_to EE __ __end; ___if remove > GROUP[gno] then __ ____begin _____writetext(|<Saa mange er der ikke i bunken. De fjerner altsaa hele bunken.|); < >LINE; remove := GROUP[gno]end if too many ___end if more than one; ___GROUP[gno] := GROUP[gno] - remove;if longtext then longtext := false; __ ____ _____DISPLAY BITS(gno); FIND SUM;II: if boolsum | 0 then __ = ____begin _____SHIFT(4);if winmessage ∧ -, wrongmessage then __ ____begin _____writechar(29);writetext(|<Det var forkert. Nu kan De ikke vinde.|); < >FF: loosemessage := wrongmessage := true; ____writechar(62); LINEend of blunder; ___if loosemessage then __ ____begin _____ask := ask + 1;if ask _ 3⨯3 = ask then __ : ____begin _____SHIFT(4); writetext(|<Hvis De giver fortabt, saa skriv et 1-tal her: |); < >t := type char; LINE;if t = 1 then go_to ASK FOR MORE __ ____ __ __end if third time; ___commen_ - -8- ______DEMON-1D ;go_to GIERMOVE __ __end; ___writechar(29);writetext(|<De kan ikke vinde dette spil.|); < >go_to FF __ __end if boolsum | 0; ___ =if aritsum = 0 then __ ____begin _____SHIFT(4);writetext(|<De har vundet. Tillykke.|); < >go_to ASK FOR MORE __ __end if finished; ___if -, winmessage then __ ____begin _____SHIFT(4);winmessage := true; ____writechar(29);writetext(|<Hvis De spiller rigtigt, kan De vinde dette spil.|); < >writechar(62); LINEend if not winmessage; ___GMAX := GROUP[1]; gno := 1;for g := 2 step 1 until G do ___ ____ _____ __begin _____if GROUP[g] > GMAX then __ ____begin _____GMAX := GROUP[g]; gno := gend ___end search of largest group; ___remove := 1; JJ: GROUP[gno] := GROUP[gno] - remove; SHIFT(4);if GROUP[gno] > 0 then __ ____begin _____writetext(|<Jeg fjerner nu|); < >write(|-ndd|, remove); < >commen_ - -9- ______DEMON-1D ;writetext(|< fra bunke nr.|) < >end group not empty ___else ____writetext(|<Jeg fjerner nu hele bunke nr.|); < >write(|-ndd|, gno); < >writetext(|<. Bunkerne indeholder nu:|); < >LINE; LINE; PRINTGROUPS; DISPLAY BITS (gno); FIND SUM;if aritsum > 0 then go_to GG; __ ____ __ __SHIFT(4); LINE;writetext(|<De har tabt.|); < >ASK FOR MORE: LINE;newnim := false; _____HH: writetext(|< <Hvis De ønsker at prøve igen, saa skriv et 1-tal her, ellers et 2-tal: |); >linerest := linerest - 1; t := type char;if t | 1 ∧ t | 2 then go_to HH; __ = = ____ __ __LINE; LINE;go_to if t = 1 then AGAIN else RESTART; __ __ __ ____ ____GIERMOVE: for g := 1 step 1 until G do ___ ____ _____ __begin _____if boolsum = GROUP[g] then __ ____begin _____remove := boolsum; gno := g;go_to JJ __ __end if remove whole group ___end for g; ___for n := N step -1 until 1 do ___ ____ _____ __begin _____if SUM[n] = 1 then __ ____begin _____nmax := n;commen_ - -10- ______DEMON-1D ;go_to KK __ __end hit ___end for n; ___KK: for g := 1 step 1 until G do ___ ____ _____ __begin _____if BITS[g, nmax] = 1 then __ ____begin _____gno := g; remove := 0; fact := 1;for n := 1 step 1 until nmax do ___ ____ _____ __begin _____if SUM[n] = 1 then __ ____remove := remove + (if BITS[gno, n] = 1 then fact else - fact) __ ____ ____; fact := fact⨯2end for n; ___go_to JJ __ __end if hit Bits ___end for g; ___go_to HH __ __end inner NIM-block ___end NIM; ___MAP:begin comment MAP-block; _____ _______boolean red, even; _______integer a, amin, amax, b, bs, fh, fhmin, fhmax, fv, fvmin, fvmax, h, hs, _______k, n, ncon, nmap, p, p2, p3, q, r, r1, r2, s, s1, s2, spr;real d, dmin, e, f, g, j, v; ____SHIFT(10);writetext(|<Type 2. Trykning af tilfældige landkort.|); < >LINE; LINE;if newmap then __ ____begin _____SHIFT(18);commen_ - -11- ______DEMON-1D ;writetext(|< <Følgende parametre bruges i dette program: Typiske værdier: nmap: Antal landkort. 1 h: Kortenes højde. 60 b: Kortenes bredde. 80 hs: Højde af delkort. 15 bs: Bredde af delkort. 20 ncon: Antal lande per delkort. 1 fh: Vandret skalafaktor. 1-5 Minimum: fhmin, maximum: fhmax. fv: Lodret skalafaktor. 1-5 Minimum: fvmin, maximum: fvmax. a: Drejningsvinkel. 45 Minimum: amin, maximum: amax. spr: Spredningsfaktor: Minimum 1, maximum 10 1|); >linerest := linerest - 16;newmap := false _____end if newmap; ___LL: LINE; SHIFT(5);writetext(|< <Opgiv parametrene: nmap h b hs bs ncon fhmin fhmax fvmin fvmax amin amax spr|); >nmap := type in; h := type in; b := type in; hs := type in; bs := type in; ncon := type in; fhmin := type in; fhmax := type in; fvmin := type in; fvmax := type in; amin := type in; amax := type in; spr := type in;r1 := h _ hs; :s1 := b _ bs; :p2 := r1⨯s1⨯ncon; linerest := linerest - 3; LINE;for n := 1 step 1 until nmap do ___ ____ _____ __begin comment inner MAP-block; _____ _______integer array cx, cy, fh, fv[1:p2]; _______ _____array cosv, sinv[1:p2]; _____commen_ - -12- ______DEMON-1D ; p := 0;for r := 1 step 1 until r1 do ___ ____ _____ __for s := 1 step 1 until s1 do ___ ____ _____ __for q := 1 step 1 until ncon do ___ ____ _____ __begin _____p := p+1;cx[p] := (s-1)⨯bs + bs_2 + (RANDOM(bs) - bs_2)_spr; : : :cy[p] := (r-1)⨯hs + hs_2 + (RANDOM(hs) - hs_2)_spr; : : :fh[p] := fhmin + RANDOM(fhmax-fhmin) - 1;if fh[p] < 1 then fh[p] := 1; __ ____fv[p] := fvmin + RANDOM(fvmax-fvmin) - 1;if fv[p] < 1 then fv[p] := 1; __ ____v := 3.14159265/180⨯(amin + RANDOM(amax-amin)); cosv[p] := cos(v); sinv[p] := sin(v)end for q, s, and r; ___SHIFT(h+3); LINE; writechar(62);red := false; _____for r := 1 step 1 until h do ___ ____ _____ __begin _____for s := 1 step 1 until b do ___ ____ _____ __begin _____dmin := 110 5;for p := 1 step 1 until p2 do ___ ____ _____ __begin _____e := cx[p]; f := cy[p]; g := cosv[p]; j := sinv[p];d := (((e-s)⨯g - (f-r)⨯j)/fv[p])∧2 |+ (((e-s)⨯j + (f-r)⨯g)/fh[p])∧2; |if d < dmin then __ ____begin _____dmin := d; p3 := pend if lower distance ___end for p; ___p3 := p3 - 1;p3 := p3 - p3 _ 35⨯35 + 1; :commen_ - -13- ______DEMON-1D ;even := p3 = p3 _ 2⨯2; :if p3 > 9 then __ ____p3 := if p3 < 19 then p3 + 39 __ ____else ____if p3 < 28 then p3 + 14 else p3 - 10; __ ____ ____if even _ red then __ = ____begin _____writechar(if red then 62 else 29); __ ____ ____red := -, redend; ___writechar(p3)end for s; ___LINEend for r ___end inner MAP-block; ___LINE; LINE; LINE; SHIFT(4); writechar(62);writetext(|<Hvis De ønsker flere kort, saa skriv et 1-tal her: |); < >r := type char;go_to if r = 1 then LL else RESTART __ __ __ ____ ____end of MAP-block; ___LINEQ:begin comment LINEQ-block; _____ _______integer N, i, j; _______SHIFT(10);writetext(|<Type 3. Løsning af tilfældige lineære ligninger.|); < >LINE; LINE;if newlineq then __ ____begin _____SHIFT(5);writetext(|< <Programmet genererer og løser et sæt af N tilfældige lineære ligninger. Maximumværdien af N er 24. Regnetiden for N = 20 er 23 sec. i ALGOL og 4 sec. i maskinsprog. Opgiv N = 0 for stop.|); >linerest := linerest - 4;newlineq := false _____end if newlineq; ___MM: LINE;commen_ - -14- ______DEMON-1D ; SHIFT(4);writetext(|<Opgiv N: |); < >N := type in; LINE;if N > 24 then N := 24; __ ____if N = 0 then go_to RESTART; __ ____ __ __begin comment inner LINEQ-block; _____ _______array x[1:N], MATRIX[1:N, 1:N + 1]; _____procedure LINEQ1 (N, a, x, NOSOLUTION); _________integer N; _______array a, x; _____label NOSOLUTION; _____begin _____integer p, i, j; _______real M; ____for p := 1 step 1 until N - 1 do ___ ____ _____ __begin _____for i := p + 1 step 1 until N do ___ ____ _____ __begin _____if a[p,p] | 0 then go_to L2; __ = ____ __ __if a[i,p] | 0 then go_to L1; __ = ____ __ __if i < N then go_to L3; __ ____ __ __go_to NOSOLUTION; __ __L1: for j := p step 1 until N + 1 do ___ ____ _____ __begin _____M := a[p,j]; a[p,j] := a[i,j]; a[i,j] := Mend of row exchange; ___go_to L3; __ __L2: if a[i,p] = 0 then go_to L3; __ ____ __ __M := -a[i,p]/a[p,p];for j := p+1 step 1 until N+1 do ___ ____ _____ __a[i,j] := a[i,j] + M⨯a[p,j];L3: end for i; ___end for p; ___if a[N,N] = 0 then go_to NOSOLUTION; __ ____ __ __for p := N step -1 until 1 do ___ ____ _____ __begin _____x[p] := a[p,N+1] := a[p,N+1]/a[p,p];commen_ - -15- ______DEMON-1D ;if p = 1 then go_to L4; __ ____ __ __for i := p-1 step -1 until 1 do ___ ____ _____ __a[i,N+1] := a[i,N+1] - x[p]⨯a[i,p]end for second p; ___L4: end LINEQ-1; ___NN: for i := 1 step 1 until N do ___ ____ _____ __for j := 1 step 1 until N+1 do ___ ____ _____ __MATRIX[i,j] := RANDOM(30000); LINEQ1(N, MATRIX, x, ERROR);go_to MM; __ __ERROR: SHIFT(4); LINE;writetext(|<Undskyld, determinanten er nul. Her er et andet eksempel.| < >); LINE;go_to NN __ __end of inner LINEQ-block ___end of LINEQ-block; ___PRIME:begin comment prime block; _____ _______boolean first, last, small; _______integer type, num, num1, fact, count, A, B; _______integer procedure PRIM1(x); _______ _________integer x; _______begin _____integer y; _______A: PRIM1 := x := x + 2; y := 1;for y := y + 2 while y⨯y_x do ___ _____ < __if (x_y)⨯y = x then go_to A __ : ____ __ __end; ___procedure READ(number, text); _________integer number; _______string text; ______begin _____real N; ____PP: SHIFT(4); writetext(text); N := type in; LINE;if N < 1 ∨ N > 536870911 then go_to PP; __ ____ __ __commen_ - -16- ______DEMON-1D ; number := Nend READ; ___SHIFT(10);writetext(|<Type 4. Beregning af primtal.|); < >LINE; LINE;if newprime then __ ____begin _____SHIFT(8);writetext(|< <Programmet indeholder to beregningstyper: 1. Beregning af primfaktorer i et opgivet tal, N. 2. Beregning af primtal i et opgivet interval fra A til B. Opgiv type 3 for stop. Øvre grænse for tallene er 536870911.|); >linerest := linerest - 5;newprime := false _____end of newprime; ___OO: LINE;READ(type, |<Opgiv primtalberegningstype: |); < >if type = 1 then __ ____begin _____READ(num, |<Opgiv tallet, N: |); < >num1 := num;first := true; ____last := false; _____if num < 4 then __ ____QQ: begin _____writetext(|<Primtal|); < >go_to OO __ __end; ___for fact := 2, 3, PRIM1(fact) while fact⨯fact _ num1 ∧ num > 1 do ___ _____ < __begin _____count := 0;RR: if num_fact⨯fact = num then __ : ____SS: begin _____count := count + 1;num := num_fact; :if first then writetext(|<=|); __ ____ < >if count = 1 then __ ____begin _____if -, first then writetext(|<⨯|); __ ____ < >commen_ - -17- ______DEMON-1D ;first := false; _____write(if fact < 10 then |d| __ ____ < >else if fact < 100 then |dd| ____ __ ____ < >else if fact < 1000 then |ddd| ____ __ ____ < >else if fact < 10000 then |dddd| ____ __ ____ < >else |ddddddddd|, fact) ____ < >end if count = 1; ___go_to if last then OO else RR __ __ __ ____ ____end if divisor; ___if count > 1 then __ ____begin _____writetext(|<∧|); < |>write(if count < 10 then |d| else |dd|, count) __ ____ < > ____ < >end if power printing; ___count := 0end for fact; ___if first then go_to QQ; __ ____ __ __last := true; ____fact := num;if num > 1 then go_to SS; __ ____ __ __go_to OO __ __end if type = 1 ___else ____if type = 2 then __ ____begin _____READ(A, |<Opgiv nedre grænse, A: |); < >READ(B, |<Opgiv øvre grænse, B: |); < >small := B < 10000; count := 0;fact := if small then 10 else 8; __ ____ ____SHIFT(4);if A = 1 then A := 2 __ ____else ____if A > 3 then __ ____begin _____A := A - (if A_2⨯2 = A then 1 else 2); __ : ____ ____UU: A := PRIM1(A)end; ___TT: if count_fact⨯fact = count then LINE; __ : ____count := count + 1;if A_B then write(if small then |-ddddd| else |-ddddddddd|, A); __ < ____ __ ____ < > ____ < >commen_ - -18- ______DEMON-1D ;if A < B then __ ____begin _____if A = 2 then __ ____begin _____A := 3;go_to TT __ __end; ___go_to UU __ __end; ___go_to OO __ __end type = 2 ___else ____go_to RESTART __ __end prime block; ___LANU:begin comment large number calculation block; _____ _______boolean first, out; _______integer M, carry, count, c1, c2, d1, d2, type, N, alimit, asize, nn, a, _______b, D, bsize, m;procedure READ(number, text); _________integer number; _______string text; ______begin _____SHIFT(4); writetext(text); number := type in; LINEend READ; ___procedure ALARM(n); _________value n; _____integer n; _______writetext(|< <FEJL |, if n = 1 then |<1| else |<2|); > __ ____ < > ____ < >procedure MULT(n, A, size); _________value n; _____integer n, size; _______integer array A; _______ _____begin _____carry := 0;commen_ - -19- ______DEMON-1D ;for count := 0 step 1 until alimit do ___ ____ _____ __begin _____c1 := A[count];c2 := c1_M; :c1 := (c1-c2⨯M)⨯n + carry;carry := c1_M; :c1 := c1 - carry⨯M; c2 := c2⨯n + carry;carry := c2_M; :A[count] := (c2-carry⨯M)⨯M + c1;if count = size then __ ____begin _____if carry = 0 then go_to ex __ ____ __ __else ____if count < alimit then size := size + 1 __ ____else ____ALARM(1)end if count ___end for count; ___ex: end MULT; ___procedure DIV(n, A, size, empty); _________value n; _____integer n, size; _______boolean empty; _______integer array A; _______ _____begin _____first := true; ____carry := 0;for count := size step -1 until 0 do ___ ____ _____ __begin _____c1 := A[count];c2 := c1_M; :c1 := c1 - c2⨯M; carry := carry⨯M + c2;c2 := carry_n; :carry := (carry - c2⨯n)⨯M + c1;c1 := carry_n; :carry := carry - c1⨯n; A[count] := c1 := c1 + c2⨯M;commen_ - -20- ______DEMON-1D ;if first then __ ____begin _____if c1 > 0 then first := false __ ____ _____else ____if size > 0 then size := size - 1 __ ____end if first ___end for count; ___empty := first ∧ c1 = 0end DIV; ___procedure ADD(plus, A, B, asize, bsize); _________value plus, bsize; _____boolean plus; _______integer asize, bsize; _______integer array A, B; _______ _____begin _____carry := 0;for count := 0 step 1 until alimit do ___ ____ _____ __begin _____c1 := A[count]; d1 := B[count];c2 := c1_M; d2 := d1_M; : :c1 := c1-c2⨯M; d1 := d1 - d2⨯M;c1 := c1 + (if plus then d1 else - d1) + carry; __ ____ ____carry := 0;L1: if c1 < 0 then __ ____begin _____c1 := c1 + M; carry := carry - 1;go_to L1 __ __end if c1 negative; ___d1 := c1_M; :c1 := c1 - d1⨯M;c2 := c2 + (if plus then d2 else - d2) + d1 + carry; __ ____ ____carry := 0;L2: if c2 < 0 then __ ____begin _____c2 := c2 + M; carry := carry - 1;go_to L2 __ __end if c2 negative; ___d1 := c2_M; :commen_ - -21- ______DEMON-1D ; c2 := c2 - d1⨯M; carry := carry + d1; A[count] := c1 := c1 + c2⨯M;if count _ bsize ∧ carry = 0 then go_to L3 __ > ____ __ __end for count; ___if carry | 0 then ALARM(2); __ = ____L3: first := true; ____for count := alimit step -1 until 0 do ___ ____ _____ __begin _____asize := count;if A[count] | 0 then go_to L4 __ = ____ __ __end; ___L4: end ADD; ___procedure P4(n); _________value n; _____integer n; _______begin _____integer i, z, D, a; _______D := 1000;z := if first then 0 else 16; __ ____ ____for i := 1 step 1 until 4 do ___ ____ _____ __begin _____a := n_D; :n := n - a⨯D;if a | 0 then __ = ____begin _____writechar(a);first := false; _____z := 16end ___else writechar(z); ____D := D_10 :end for i ___end P4; ___procedure PR(A, size); _________value size; _____integer size; _______array A; _____begin _____first := true; ____commen_ - -22- ______DEMON-1D ; d1 := 0;for count := size step -1 until 0 do ___ ____ _____ __begin _____c1 := A[count];c2 := c1_M; :c1 := c1 - c2⨯M; P4(c2); skrvml(1); P4(c1); skrvml(1); d1 := d1 + 1;if d1_8⨯8 = d1 then LINE __ : ____end for count ___end PR; ___SHIFT(10);writetext(|<Type 5. Beregning af store tal.|); < >LINE; LINE;if newlanu then __ ____begin _____SHIFT(8);writetext(|< <Programmet indeholder fire beregningstyper: 1. Beregning af fakultet: FAC(N) = 1⨯2⨯3⨯4........⨯N.2. Beregning af potens: a∧b. |3. Beregning af e = 2.718 ...... med D cifre. 4. Beregning af pi = 3.1415.... med D cifre. 5. giver programstop.|); >linerest := linerest - 7;newlanu := false _____end of newlanu; ___LINE; M := 10000;VV: READ(type, |<Opgiv beregningstype for store tal: |); < >if type = 1 then __ ____begin _____READ(N, |<Opgiv N:|); < >if N > 1000 then N := 1000; __ ____alimit := 0.05⨯N⨯ln(N);begin _____integer array FAC[0:alimit]; _______ _____commen_ - -23- ______DEMON-1D ;for count := 0 step 1 until alimit do FAC[count] := 0; ___ ____ _____ __asize := 0; FAC[0] := 1;for nn := 1 step 1 until N do MULT(nn, FAC, asize); ___ ____ _____ __LINE; LINE; SHIFT(4);writetext(|<FAC :=|); < >LINE; PR(FAC, asize); LINE;go_to VV __ __end block ___end if type = 1 ___else ____if type = 2 then __ ____begin _____READ(a, |<Opgiv a: |); < >READ(b, |<Opgiv b: |); < >alimit := 1 + 0.055⨯b⨯ln(a);begin _____integer array POT[0:alimit]; _______ _____for count := 0 step 1 until alimit do POT[count] := 0; ___ ____ _____ __asize := 0; POT[0] := 1;for nn := 1 step 1 until b do MULT(a, POT, asize); ___ ____ _____ __LINE; LINE; SHIFT(4);writetext(|<a∧b := |); < | >LINE; PR(POT, asize); LINE;go_to VV __ __end block ___end if type = 2 ___else ____if type < 5 then __ ____begin _____READ(D, |<Opgiv D: |); < >alimit := D_8; :commen_ - -24- ______DEMON-1D ;if alimit⨯8 | D then __ = ____begin _____writetext(|<D er ændret til:|); < >alimit := alimit + 1; D := 8⨯alimit;write(|nddd|, D); < >LINEend; ___D := 8⨯alimitend ___else go_to RESTART; ____ __ __if type = 3 then __ ____begin _____integer array RESULT, TERM[0:alimit]; _______ _____for count := 0 step 1 until alimit do ___ ____ _____ __RESULT[count] := TERM[count] := 0; asize := bsize := alimit; RESULT[alimit] := 2; TERM[alimit] := 1;out := false; _____m := 1;for m := m + 1 while -, out do ___ _____ __begin _____DIV(m, TERM, bsize, out);ADD(true, RESULT, TERM, asize, bsize) ____end for m; ___LINE; LINE; SHIFT(4);writetext(|<e⨯10∧D := |); < | >LINE; PR(RESULT, asize); LINE;go_to VV __ __end block if type = 3 ___else ____begin _____boolean out1, out2, out3, plus; _______integer t1size, t2size, t3size, ssize; _______integer array RESULT, T1, T2, T3, SUM[0:alimit]; _______ _____commen_ - -25- ______DEMON-1D ;for count := 0 step 1 until alimit do ___ ____ _____ __RESULT[count] := T1[count] := T2[count] := T3[count] := 0; T1[alimit] := T2[alimit] := T3[alimit] := 24; asize := t1size := t2size := t3size := alimit; DIV(8, T1, t1size, out1); DIV(171, T2, t2size, out2); DIV(1434, T3, t3size, out3);plus := false; _____m := -1;for m := m + 2 while -, out1 do ___ _____ __begin _____for count := 0 step 1 until alimit do SUM[count] := 0; ___ ____ _____ __ssize := 0;ADD(true, SUM, T1, ssize, t1size); ____if -, out2 then ADD(true, SUM, T2, ssize, t2size); __ ____ ____if -, out3 then ADD(true, SUM, T3, ssize, t3size); __ ____ ____DIV(m, SUM, ssize, out); plus := -, plus; ADD(plus, RESULT, SUM, asize, ssize); DIV(64, T1, t1size, out1);if -, out2 then DIV(3249, T2, t2size, out2); __ ____if -, out3 then for nn := 1,2 do DIV(239, T3, t3size, out3) __ ____ ___ __end for m; ___LINE; LINE; SHIFT(4);writetext(|<pi⨯10∧D :=|); < | >LINE; PR(RESULT, asize); LINE;go_to VV __ __end type = 4 ___end LANU-block; ___FINISH:end of program DEMON-1D; ___