- Tema Autor
- #1
Gracias por leer mi mensaje aca les dejo el codigo ya me an ayudado un amigo. gracias nuevamente =)...
Buen día compañeros, estoy aquí para saber si alguien sabe programar en delphi (Object Pascal) me seria muy útil si alguien me pudiera orientar acerca de métodos de ordenamiento, igual si alguien tuviera un ejemplo se los agradecería mucho. Gracias.

unit CapturaNumeros;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls, Buttons;
type
TForm1 = class(TForm)
Panel1: TPanel;
Panel2: TPanel;
Panel3: TPanel;
Panel4: TPanel;
Panel5: TPanel;
MemoSinOrdenar: TMemo;
EditNumero: TEdit;
Label1: TLabel;
ButtonOrdenar: TButton;
BitBtnSalir: TBitBtn;
Label2: TLabel;
MemoNumerosOrdenados: TMemo;
Label3: TLabel;
procedure ButtonOrdenarClick(Sender: TObject);
procedure EditNumeroKeyPress(Sender: TObject; var Key: Char);
procedure FormShow(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
uses Math;
{$R *.dfm}
procedure TForm1.ButtonOrdenarClick(Sender: TObject);
//Ordenamiento
var
Lista: array[1..20] of integer;
Puntero : integer;
Indice : integer;
Indice_Auxiliar: integer;
valor : integer;
FlagStop : boolean;
begin
for Indice := 1 to 20 do
begin
Lista[Indice] := 0;
end;
for Indice := 0 to (MemoSinOrdenar.Lines.Count-1) do
begin
if MemoSinOrdenar.Lines[Indice] <> '' then
begin
valor := StrToInt(MemoSinOrdenar.Lines[Indice]);
Puntero := 1;
FlagStop := False;
while (Puntero <= Indice+1) and (not FlagStop) do
begin
if (Puntero = 1) and ((Indice+1) = 1) then
begin
Lista[Puntero] := valor;
end
else
if (Lista[Puntero] > valor) then
begin
for Indice_Auxiliar := (Indice+1) downto (Puntero+1) do
begin
FlagStop := True;
Lista[Indice_Auxiliar] := Lista[Indice_Auxiliar-1];
end;
Lista[Puntero] := valor;
end;
Puntero := Puntero + 1;
end;
end;
end;
for Indice := 0 to (MemoSinOrdenar.Lines.Count - 1) do
begin
MemoNumerosOrdenados.Lines.Add(IntToStr(Lista[Indice+1]))
end;
end;
procedure TForm1.EditNumeroKeyPress(Sender: TObject; var Key: Char);
//programamos el boton
begin
if key = #13 then
begin
if EditNumero.Text <> '' then
begin
try
StrToInt(EditNumero.Text);
MemoSinOrdenar.Lines.Add(EditNumero.Text);
EditNumero.Clear;
except
MessageDlg('Solo se aceptan numeros', mtInformation, [mbOk], 0);
EditNumero.Clear;
EditNumero.SetFocus;
end;
end;
end;
end;
procedure TForm1.FormShow(Sender: TObject);
begin
//acomodamos el apuntador en el campo EditNumero
EditNumero.SetFocus;
end;
end.
Buen día compañeros, estoy aquí para saber si alguien sabe programar en delphi (Object Pascal) me seria muy útil si alguien me pudiera orientar acerca de métodos de ordenamiento, igual si alguien tuviera un ejemplo se los agradecería mucho. Gracias.

