with Ada.Text_Io, Ada.Integer_Text_Io; use Ada.Text_Io, Ada.Integer_Text_Io; procedure Sudoku_A_trous is --------------- begin définitions d'une grille ---------------- subtype Symbole is Integer range 0..9; type Grille is array(1..9, 1..9) of Symbole; type Tbl9 is array(Symbole'Range) of Symbole; type TblSol is array(Symbole'Range) of Boolean; procedure Get(G : in out Grille) is begin for X in Grille'Range(1) loop for Y in Grille'Range(2) loop Get(G(X, Y)); end loop; end loop; end; --------------- end définitions d'une grille ---------------- --------------- begin définitions des Piles ------------------- type Pile is record Head : Integer; Data : Tbl9; end record; PileVide : constant Pile := (0, (others => 0)); function Sommet(P : in Pile) return Symbole is begin return P.Data(P.Head); end; procedure Empiler(P : in out Pile; V : in Symbole) is begin P.Head := P.Head + 1; P.Data(P.Head) := V; end; procedure Depiler(P : in out Pile) is begin P.Head := P.Head - 1; end; function Vide(P : in Pile) return Boolean is begin return P.Head = 0; end; procedure Put(P : in Pile) is Pp : Pile := P; begin if not Vide(Pp) then Depiler(Pp); Put(Pp); Put(Sommet(P), 2); end if; end; --------------- end définitions des Piles ------------------- --------------- begin vos réponses ici... ------------------- ------------------------------------------------------- ------------------------------------------------------- -- Question 1 procedure Put(G : in Grille) is begin null; end; -- Question 2 function Intersection(P1, P2 : in Pile) return Pile is begin return PileVide; end; -- Question 3 procedure RemplirPile(Sol : in TblSol; P : out Pile) is begin P := PileVide; end; -- Question 4 function TrouverSolCol(G : in Grille; X : in Integer) return Pile is begin return PileVide; end; -- Question 5 function TrouverSolLig(G : in Grille; Y : in Integer) return Pile is begin return PileVide; end; -- Question 6 function TrouverSolReg(G : in Grille; X, Y : in Integer) return Pile is begin return PileVide; end; -- Question 7 function TrouverSol(G : in Grille; X, Y : in Integer) return Pile is begin return PileVide; end; -- Question 8 procedure TrouverPremiereCaseVide(G : in Grille; X, Y : out Integer) is begin X := 0; Y := 0; end; -- Question 9 procedure Solve(G : in Grille; Solved : in out Boolean; GSolved : in out Grille) is begin null; end; -- Question 10 -- ? --------------- end vos réponses ici... ------------------- -- G : Grille; -- Gsolved : Grille; -- Solved : Boolean := false; P, P2 : Pile; begin P := PileVide; Empiler(P, 1); Empiler(P, 2); Empiler(P, 5); Empiler(P, 9); P2 := PileVide; Empiler(P2, 2); Empiler(P2, 3); Empiler(P2, 5); Empiler(P2, 8); Put("P : "); Put(P); New_Line; Put("P2 : "); Put(P2); New_Line; Put("P inter P2 : "); Put(Intersection(P, P2)); New_Line; Put("Intersection normale : 2 5"); New_Line; -- à décommenter pour tester le sudoku -- Get(G); -- Solve(G, Solved, Gsolved); -- if (Solved) then -- Put(Gsolved); -- else -- Put("no solution found !"); -- end if; end;