Académique Documents
Professionnel Documents
Culture Documents
interface
uses
type
TForm1 = class(TForm)
StringGrid1: TStringGrid;
StringGrid2: TStringGrid;
BitBtn1: TBitBtn;
BitBtn2: TBitBtn;
BitBtn3: TBitBtn;
MaskEdit1: TMaskEdit;
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
N:integer;
implementation
{$R *.dfm}
var
l, b, m : integer;
begin
b := 1;
l := asta;
repeat
b := m + 1
else
l := m - 1
else
l := - 1;
until l <= b;
if l = - 1 then
metodo_binaria := m
else
metodo_binaria := 0;
end;
procedure burbuja;
var i,j:integer;
Aux:integer;
Begin
for I :=1 to N - 1 Do
for J :=1 to N - I Do
Begin
Aux :=vector[J];
vector[J] :=vector[J+1];
vector[J+1] :=Aux;
End;
End;
var y:Integer;
begin
n:=14;
for y:=1 to N do
Begin
StringGrid1.cells[1,y]:=inttostr(Random(99));
stringgrid1.cells[0,Y]:=inttostr(Y);
end;
end;
var i:integer;
begin
for i:=1 to 14 do
vector[i]:= StrToInt(StringGrid1.Cells[1,i]);
StringGrid2.cells[0,i]:=inttostr(i);
burbuja;
for i:=1 to n do
StringGrid2.cells[1,i]:=inttostr(vector[i]);
end;
procedure TForm1.BitBtn3Click(Sender: TObject);
var c:integer;
begin
c:=metodo_binaria(14,14);
if c = -1 then
else
begin
end;
end;
begin
n:=14
end;
end.