Ordenamiento Burbuja
pascal:
program Burbuja;
uses CRT,chuchox;
Var
Vec : V2;
J,I,aux,h,x : Integer;
entro : Boolean;
Procedure Burbu;
Begin
For J:=1 to 9 do
Begin
entro:=false;
For I:=1 to 9 do
Begin
If Vec[I] > Vec[i+1] then
Begin
Aux:=Vec[i];
Vec[i]:=Vec[I+1];
Vec[I+1]:=Aux;
Entro:=True;
display(Vec,H);
h:=h+3;
End;
End;
If entro=False then J:=9;
End;
End;
Begin
Clrscr;
h:=1;
Randomize;
Llenar(vec,vec);
Burbu;
GotoXY(1,15);Writeln('Metodo Burbuja');
Repeat Until Keypressed;
End.
{
*****************************************
Archivo CHUCHOX.TPU
*****************************************
}
UNIT Chuchox;
INTERFACE
Uses Crt;
Type
V2 = Array[1..10] of integer;
Var
Con : Integer;
Vec : Array[1..10] of integer;
Procedure Llenar(vec:V2; Var Vec2:V2);
Procedure Display(V:V2; hh:Integer);
IMPLEMENTATION
Procedure Llenar(vec:V2; Var Vec2:V2);
Begin
For Con:=1 to 10 do Vec[Con]:=Random(100);
Vec2:=Vec;
End;
Procedure Display(V:V2; hh:Integer);
Begin
For Con:=1 to 10 do
Begin
GotoXY(hh,Con);Writeln(V[Con]);
Delay(150)
End;
End;
Begin
Randomize;
End.
{
*****************************************
Archivo CHUCHOX.PAS
*****************************************
}
UNIT Chuchox;
INTERFACE
Uses Crt;
Type
V2 = Array[1..10] of integer;
Var
Con : Integer;
Vec : Array[1..10] of integer;
Procedure Llenar(vec:V2; Var Vec2:V2);
Procedure Display(V:V2; hh:Integer);
IMPLEMENTATION
Procedure Llenar(vec:V2; Var Vec2:V2);
Begin
For Con:=1 to 10 do
Begin
Vec[Con]:=Random(100);
End;
Vec2:=Vec;
End;
Procedure Display(V:V2; hh:Integer);
Begin
For Con:=1 to 10 do
Begin
GotoXY(hh,Con);Writeln(V[Con]);
Delay(150)
End;
End;
Begin
Randomize;
End.
uses CRT,chuchox;
Var
Vec : V2;
J,I,aux,h,x : Integer;
entro : Boolean;
Procedure Burbu;
Begin
For J:=1 to 9 do
Begin
entro:=false;
For I:=1 to 9 do
Begin
If Vec[I] > Vec[i+1] then
Begin
Aux:=Vec[i];
Vec[i]:=Vec[I+1];
Vec[I+1]:=Aux;
Entro:=True;
display(Vec,H);
h:=h+3;
End;
End;
If entro=False then J:=9;
End;
End;
Begin
Clrscr;
h:=1;
Randomize;
Llenar(vec,vec);
Burbu;
GotoXY(1,15);Writeln('Metodo Burbuja');
Repeat Until Keypressed;
End.
{
*****************************************
Archivo CHUCHOX.TPU
*****************************************
}
UNIT Chuchox;
INTERFACE
Uses Crt;
Type
V2 = Array[1..10] of integer;
Var
Con : Integer;
Vec : Array[1..10] of integer;
Procedure Llenar(vec:V2; Var Vec2:V2);
Procedure Display(V:V2; hh:Integer);
IMPLEMENTATION
Procedure Llenar(vec:V2; Var Vec2:V2);
Begin
For Con:=1 to 10 do Vec[Con]:=Random(100);
Vec2:=Vec;
End;
Procedure Display(V:V2; hh:Integer);
Begin
For Con:=1 to 10 do
Begin
GotoXY(hh,Con);Writeln(V[Con]);
Delay(150)
End;
End;
Begin
Randomize;
End.
{
*****************************************
Archivo CHUCHOX.PAS
*****************************************
}
UNIT Chuchox;
INTERFACE
Uses Crt;
Type
V2 = Array[1..10] of integer;
Var
Con : Integer;
Vec : Array[1..10] of integer;
Procedure Llenar(vec:V2; Var Vec2:V2);
Procedure Display(V:V2; hh:Integer);
IMPLEMENTATION
Procedure Llenar(vec:V2; Var Vec2:V2);
Begin
For Con:=1 to 10 do
Begin
Vec[Con]:=Random(100);
End;
Vec2:=Vec;
End;
Procedure Display(V:V2; hh:Integer);
Begin
For Con:=1 to 10 do
Begin
GotoXY(hh,Con);Writeln(V[Con]);
Delay(150)
End;
End;
Begin
Randomize;
End.
November 23rd, 2007 at 10:35 am
[...] Implementación en Turbo Pascal [...]