(Gast)
n/a Beiträge
|
AW: funktion erstellen... weiß nicht weiter
17. Aug 2011, 16:55
kann hier jemand den fehler entdecken?
Delphi-Quellcode:
unit sortierenShell;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Memo1: TMemo;
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
procedure ShellSort(CharTable: String);
{ Private-Deklarationen }
public
{ Public-Deklarationen }
end;
var
Form1: TForm1;
CharTable: array[0..51] of String =
(' A', ' a', ' B', ' b', ' C', ' c', ' D', ' d', ' E', ' e', ' F', ' f', ' G', ' g', ' H',
' h',' I', ' i', ' J', ' j', ' K', ' k', ' L', ' l', ' M', ' m', ' N', ' n', ' O', ' o',
' P', ' p', ' Q', ' q', ' R', ' r', ' S', ' s', ' T', ' t', ' U', ' u', ' V', ' v',
' W', ' w', ' X', ' x', ' Y', ' y', ' Z', ' z');
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var
i, j: Integer;
begin
ShellSort(Memo1.Lines[i]);
end;
procedure TForm1.ShellSort(CharTable: String);
var
i, j, k: Integer;
lBuffer: String;
begin
i := Length(Memo1.Text) div 2;
While i > 0 do
begin
j := k;
if Memo1.Lines[j] > Memo1.Lines[j +i] then
begin
lBuffer := Memo1.Lines[j];
Memo1.Lines[j] := Memo1.Lines[j +i];
Memo1.Lines[j +i] := lBuffer;
end else
begin
k := k +1;
if k < Length(Memo1.Text) -i then
begin
i := i div 2;
Break;
end;
end
end;
end;
end.
|