DataMuseum.dk

Presents historical artifacts from the history of:

Rational R1000/400

This is an automatic "excavation" of a thematic subset of
artifacts from Datamuseum.dk's BitArchive.

See our Wiki for more about Rational R1000/400

Excavated with: AutoArchaeologist - Free & Open Source Software.


top - download

⟦7876734fc⟧ Ada Source

    Length: 7168 (0x1c00)
    Types: Ada Source
    Notes: 03_class, FILE, R1k_Segment, e3_tag, package body Carre_Magique, seg_058de7

Derivation

└─⟦8527c1e9b⟧ Bits:30000544 8mm tape, Rational 1000, Arrival backup of disks in PAM's R1000
    └─ ⟦cfc2e13cd⟧ »Space Info Vol 2« 
        └─⟦this⟧ 

E3 Source Code



with Io_Exceptions;
with Text_Io;
package body Carre_Magique is

    package Mes_Val_Io is new Text_Io.Integer_Io (Valeur);
    package Mes_Dim_Io is new Text_Io.Integer_Io (Dimension);

    function Lire_Taille return Dimension is
        T : Dimension;
        Fichier_Es : Text_Io.File_Type;
        Juste : Boolean := False;
    begin
        while Juste = False loop
            begin
                Text_Io.Put
                   ("Entrez la taille du carre magique (nombre impair): ");
                Mes_Dim_Io.Get (T);
                if (T mod 2) /= 0 then
                    Juste := True;
                end if;
            exception
                when Io_Exceptions.Data_Error =>
                    Text_Io.Put_Line ("Par defaut le carre est de taille 5");
                    return 5;
            end;
        end loop;
        return T;
    end Lire_Taille;

    procedure Creer (C : in out Object) is
        Position_Actuelle : Position;
        V, Finale : Valeur;
        Dir : Direction;
        A, B : Dimension;
    begin
        Taille := C.Valeurs'Last;
        C.Valeurs := (others => (others => 0));
        Va_Au_Centre (Position_Actuelle);
        Dir := Nord;
        Bouger (P => Position_Actuelle, D => Dir);
        Mettre_Valeur (C => C, V => 1, P => Position_Actuelle);
        Finale := Taille * Taille;
        for V in 2 .. Finale loop
            Dir := Nord_Est;
            Bouger (P => Position_Actuelle, D => Dir);
            if C.Valeurs (Position_Actuelle.X, Position_Actuelle.Y) /= 0 then
                Dir := Nord_Ouest;
                Bouger (P => Position_Actuelle, D => Dir);
            end if;
            Mettre_Valeur (C => C, V => V, P => Position_Actuelle);
        end loop;
    end Creer;

    procedure Afficher (C : in Object) is
    begin
        Text_Io.New_Line;
        Text_Io.Put_Line ("----- Le carre magique demande -----");
        Text_Io.New_Line;
        for Y in 1 .. Taille loop
            for X in 1 .. Taille loop
                Mes_Val_Io.Put (C.Valeurs (X, Y));
            end loop;
            Text_Io.New_Line;
        end loop;
    end Afficher;

    procedure Bouger (P : in out Position; D : in Direction) is
    begin
        case D is
            when Nord =>
                P.Y := P.Y - 1;
            when Nord_Est =>
                P.Y := P.Y - 1;
                P.X := P.X + 1;
                if P.X > Taille then
                    P.X := 1;
                end if;
            when Nord_Ouest =>
                P.X := P.X - 1;
                P.Y := P.Y - 1;
                if P.X < 1 then
                    P.X := Taille;
                end if;
        end case;
        if P.Y < 1 then
            P.Y := Taille;
        end if;
    end Bouger;


    procedure Va_Au_Centre (P : in out Position) is
    begin
        P.X := Taille / 2 + 1;
        P.Y := P.X;
    end Va_Au_Centre;


    procedure Mettre_Valeur
                 (C : in out Object; V : in Valeur; P : in Position) is
    begin
        C.Valeurs (P.X, P.Y) := V;
    end Mettre_Valeur;
end Carre_Magique;

E3 Meta Data

    nblk1=6
    nid=4
    hdr6=8
        [0x00] rec0=20 rec1=00 rec2=01 rec3=03a
        [0x01] rec0=1b rec1=00 rec2=06 rec3=01a
        [0x02] rec0=24 rec1=00 rec2=03 rec3=00a
        [0x03] rec0=0a rec1=00 rec2=02 rec3=000
        [0x04] rec0=01 rec1=00 rec2=02 rec3=000
        [0x05] rec0=44 rec1=66 rec2=a4 rec3=5cf
    tail 0x21766e7f888e38c63f631 0x42a00088462060003
Free Block Chain:
  0x4: 0000  00 05 03 fc 80 07 6c 65 20 6c 6f 6f 70 07 00 25  ┆      le loop  %┆
  0x5: 0000  00 00 00 09 80 06 2e 20 54 61 69 6c 06 20 20 20  ┆      . Tail    ┆