1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
| procedure trace(x, y, x_droite, y_bas, total_posees: integer);
begin
tab[x, y] := '$';
afficher_tableau;
if (x >= dim) and (y >= dim) then exit; // point d'arrêt
if y = 1 then
begin
if x >= dim then inc(x_droite); // effet de bord
x := x_droite;
y := y_bas + 1;
if y > dim then dec(y); // effet de bord
y_bas := y;
if total_posees < dim * dim then // carré rempli ?
trace(x, y, x_droite, y_bas, total_posees + 1);
end
else
if x >= dim then
begin
if y_bas = dim then inc(x_droite); // effet de bord
x := x_droite; y := y_bas;
if total_posees < dim * dim then // carré rempli ?
trace(x, y, x_droite, y_bas, total_posees + 1);
end
else
if total_posees < dim * dim then // carré rempli ?
trace(x + 1, y - 1, x_droite, y_bas, total_posees + 1); |
Partager