Accueil     Soft. MacOSX     Soft. MacOS/PC     PHP     Python     ROMS GBA     TP d'info     DBZ-GT     Martingales     Galeries     Liens     @  

Exercice 3

program ex3;
const
dim = 20;
var
i: integer;
t: array[1..dim] of integer;

function dichotomie (u, v, n: integer): boolean;
var
w: integer;
begin
w := (u + v) div 2;
if t[w] = n then
dichotomie := true
else if w = u then
dichotomie := false
else if t[w] > n then
dichotomie := dichotomie(u, w, n)
else
dichotomie := dichotomie(w, v, n)
end;
{ dichotomie renvoie TRUE si l'element est trouve et FALSE dans le cas contraire }

begin
{ Corps du programme }
writeln('Exercice 3 www.Software-DS.com');
t[1] := 2;
t[2] := 5;
t[3] := 8;
t[4] := 9;
t[5] := 10;
t[6] := 22;
t[7] := 25;
t[8] := 28;
t[9] := 29;
t[10] := 30;
t[11] := 32;
t[12] := 33;
t[13] := 37;
t[14] := 52;
t[15] := 79;
t[16] := 81;
t[17] := 92;
t[18] := 95;
t[19] := 98;
t[20] := 101;

for i := 1 to dim do
write(t[i] : 0, ',');
writeln;

repeat
writeln('Quel element voulez vous recherchez ?');
readln(i);
until i > 0;
writeln;
writeln(dichotomie(1, dim, i));
writeln;
writeln('©2001 All Rights Reserved to www.Software-DS.com');
{ ©2001 All Rights Reserved to http://www.Software-DS.com 20/11/01 }
end.





Haut de la page - Page précédente - Page générée en 0.00229 sec.
Recherche personnalisée
 

1843763 visiteurs.   ©2001-2023 All Rights Reserved to Software-DS.com
Made with a mac  
Confidentialité