|
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 Square, seg_02fa5e
└─⟦8527c1e9b⟧ Bits:30000544 8mm tape, Rational 1000, Arrival backup of disks in PAM's R1000 └─ ⟦5a81ac88f⟧ »Space Info Vol 1« └─⟦this⟧
with Text_Io; package body Square is procedure Move (Dir : Direction) is begin case Dir is when South => null; when North => if Line = Row_Line'First then Line := Row_Line'Last; else Line := Line - 1; end if; when East => if Row = Row_Line'Last then Row := Row_Line'First; else Row := Row + 1; end if; when West => if Row = Row_Line'First then Row := Row_Line'Last; else Row := Row - 1; end if; end case; end Move; procedure Go_To_Center is begin Line := (Dim / 2) + 1; Row := (Dim / 2) + 1; end Go_To_Center; procedure Deposit (Token : in out Natural) is begin Square (Line, Row) := Token; Token := Token + 1; end Deposit; function Full return Boolean is begin if Token <= Dim * Dim then return False; else return True; end if; end Full; function Occup_Cell return Boolean is begin if Square (Line, Row) = 0 then return False; else return True; end if; end Occup_Cell; procedure Display is package Int_Io is new Text_Io.Integer_Io (Natural); begin for I in 1 .. Dim loop for J in 1 .. Dim loop Int_Io.Put (Square (I, J)); end loop; Text_Io.New_Line; end loop; end Display; procedure Verify is package Int_Io is new Text_Io.Integer_Io (Natural); Value, Result : Natural; Ok : Boolean := True; begin Value := Dim * (Dim * Dim + 1) / 2; for I in 1 .. Dim loop Result := 0; for J in 1 .. Dim loop Result := Result + Square (I, J); end loop; if Result /= Value then Ok := False; exit; end if; end loop; Text_Io.New_Line; if Ok then Text_Io.Put ("Magic Square is OK."); else Text_Io.Put ("Magic Square is NOT OK."); end if; Text_Io.New_Line; Text_Io.Put ("Sum rows & lines is : "); Int_Io.Put (Value); end Verify; end Square;
nblk1=4 nid=3 hdr6=6 [0x00] rec0=2d rec1=00 rec2=01 rec3=01e [0x01] rec0=2f rec1=00 rec2=02 rec3=00c [0x02] rec0=1a rec1=00 rec2=04 rec3=000 [0x03] rec0=0e rec1=00 rec2=02 rec3=000 tail 0x21528d2f8849186b5f9fb 0x42a00088462060003 Free Block Chain: 0x3: 0000 00 00 00 03 00 00 00 00 00 00 00 00 00 00 00 00 ┆ ┆