المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : ساعدونا هذه الخوارزمية الله يحفظلكم والديكم


Soumri
2013-03-09, 19:20
ecrire un algorithme qui permet de saisir un tableau trié de 10 entiers .puis de saisir une valeur entiére au clavier .et enfin d'afficher son indice si elle existe dans le tableau.afficher(-1) sinon.en utilisant la recherche dichotomique dans un tableau trié

Soumri
2013-03-09, 19:54
waynékoum ya khawtiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii iiiiiiiiiiiiiiiiiiiii

King Soft
2013-03-09, 21:23
السلام عليكم

تفضل اخي :



program Project1;

var debut,fin,moy,i,x:integer;
T:array[1..10]of integer;
Trouve : boolean;
begin
writeln('Remplassage du tableau :');
for i:=1 to 10 do
Read(T[i]);
writeln('Tapper x =');
Read(x);
Debut:=1;Fin:=10;
Trouve := false;
Repeat
Moy:=(Debut+Fin) Div 2;
if T[Moy] = x then
Trouve := True
else
if X > T[Moy] then
Debut := Moy+1
else
Fin := Moy - 1;
until (Trouve) or(Debut<=Fin) ;

if Trouve then
Write('Le Rang =',Moy)
else
Write('Le Rang = -1');

end.



بالتوفيق