1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77: 78: 79: 80: 81: 82: 83: 84: 85: 86: 87: 88: 89: 90: 91: 92: 93: 94: 95: 96:
| unit Unit1;
interface
uses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, ExtCtrls, StdCtrls;
type TForm1 = class(TForm) ListBox1: TListBox; Button1: TButton; Button2: TButton; Button3: TButton; Image1: TImage; procedure Button1Click(Sender: TObject); procedure shellsort (); procedure Button3Click(Sender: TObject); procedure Button2Click(Sender: TObject); private public end;
var Form1: TForm1; ZFeld : array[0..300] of integer;
implementation
{$R *.DFM}
procedure TForm1.Button3Click(Sender: TObject); begin close; end;
procedure TForm1.Button1Click(Sender: TObject); var i:integer; Zufallszahl : integer; begin randomize; for i:= 0 to 300 do begin Zufallszahl := random(100)+1; ListBox1.Items[i] := inttostr(Zufallszahl); ZFeld[i] := Zufallszahl; end; for i := 0 to 300 do begin Form1.Image1.Canvas.Pixels[i,ZFeld[i]]:=clred; end; end;
procedure TForm1.ShellSort(); var i, j, h, v: integer; begin h := 1; repeat h := ( 3 * h ) + 1; until h > length(ZFeld); repeat h := ( h div 3 ); for i := h + 1 to length(ZFeld) do begin v := ZFeld[i - 1]; j := i; while ( ( j > h ) and ( ZFeld[j - h - 1] > v ) ) do begin ZFeld[j - 1] := ZFeld[j - h - 1]; dec( j, h ); end; ZFeld[j - 1] := v; Application.ProcessMessages; end; until h = 1; end;
procedure TForm1.Button2Click(Sender: TObject); var a: array[0..300] of Integer; I: Integer; begin for I:=Low(a) to High(a) do a[I]:=Random(High(Integer));
ShellSort(); end;
end. |