|
DataMuseum.dkPresents historical artifacts from the history of: Rational R1000/400 |
This is an automatic "excavation" of a thematic subset of
See our Wiki for more about Rational R1000/400 Excavated with: AutoArchaeologist - Free & Open Source Software. |
top - download
Length: 5120 (0x1400) Types: Ada Source Notes: 03_class, FILE, R1k_Segment, e3_tag, package body Magic_Square, seg_03d512
└─⟦8527c1e9b⟧ Bits:30000544 8mm tape, Rational 1000, Arrival backup of disks in PAM's R1000 └─ ⟦cfc2e13cd⟧ »Space Info Vol 2« └─⟦this⟧
with Io; with Text_Io; package body Magic_Square is procedure Move (D : Direction) is begin case D is when Nord_Est => Row_Position := (Row_Position + 1) mod Tab_Size; if Row_Position = 0 then Row_Position := 1; end if; Col_Position := (Col_Position + 1) mod Tab_Size; if Col_Position = 0 then Col_Position := 1; end if; when Nord_Ouest => Row_Position := (Row_Position + 1) mod Tab_Size; if Row_Position = 0 then Row_Position := 1; end if; Col_Position := (Col_Position - 1) mod Tab_Size; if Col_Position = 0 then Col_Position := 1; end if; when Nord => Row_Position := (Row_Position + 1) mod Tab_Size; if Row_Position = 0 then Row_Position := 1; end if; when others => null; end case; end Move; procedure Go_To_Center is begin Row_Position := Center_Tab; Col_Position := Center_Tab; end Go_To_Center; procedure Deposit (Token : Integer) is begin Tab (Row_Position, Col_Position) := Token; end Deposit; procedure Init_Square is I, J : Integer; begin for I in 1 .. 5 loop for J in 1 .. 5 loop Tab (I, J) := 0; end loop; end loop; Row_Position := 0; Col_Position := 0; end Init_Square; procedure Affichage is I, J : Integer; begin for I in 1 .. 5 loop for J in 1 .. 5 loop Io.Put (Tab (I, J), Width => 3); end loop; Text_Io.Put_Line (""); end loop; end Affichage; procedure Calcul_Tableau is I, J, Token : Integer; Dir : Direction; begin Token := 1; Dir := Nord; Move (Dir); Deposit (Token); Dir := Nord_Est; Token := Token + 1; Move (Dir); while Token <= Tab_Capacity loop if Tab (Row_Position, Col_Position) = 0 then Deposit (Token); Token := Token + 1; Dir := Nord_Est; Move (Dir); else Dir := Nord_Ouest; Move (Dir); end if; end loop; end Calcul_Tableau; procedure Run is begin Init_Square; Affichage; Go_To_Center; Calcul_Tableau; -- Io.Put (Row_Position, Width => 2); -- Io.Put (Col_Position, Width => 2); Affichage; end Run; end Magic_Square;
nblk1=4 nid=3 hdr6=6 [0x00] rec0=1c rec1=00 rec2=01 rec3=024 [0x01] rec0=2a rec1=00 rec2=04 rec3=044 [0x02] rec0=28 rec1=00 rec2=02 rec3=000 [0x03] rec0=0b rec1=00 rec2=02 rec3=000 tail 0x2173bfb7485f84ee44029 0x42a00088462060003 Free Block Chain: 0x3: 0000 00 00 01 2a 80 07 20 20 20 20 20 20 20 07 a4 0b ┆ * ┆