Hallo, ich habe mich entschieden ein kleines "Sortierprogramm" zu schreiben.
Darin wollte ich BestCase, AverageCase, und Worst Case einbinden.
Die Auswahl von denen wollte ich durch Radios gestalten... bloß durchläuft mein Programm irgendwie
das komplette Programm... alsob er das "If Radio" etc. ignorieren würde.. ich bitte um schnelle Hilfe.
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: 97: 98: 99: 100: 101: 102: 103: 104: 105: 106: 107: 108: 109: 110: 111: 112: 113: 114: 115: 116: 117: 118: 119: 120: 121: 122: 123: 124: 125: 126: 127: 128: 129: 130: 131: 132: 133: 134: 135: 136: 137: 138: 139: 140: 141: 142: 143: 144: 145: 146: 147: 148: 149: 150: 151: 152: 153: 154: 155:
| unit Unit1;
interface
uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, ExtCtrls;
type TForm1 = class(TForm) Memo2: TMemo; Button1: TButton; Memo1: TMemo; Label1: TLabel; Edit1: TEdit; Panel1: TPanel; Panel2: TPanel; Panel3: TPanel; Panel4: TPanel; Label2: TLabel; Label3: TLabel; RadioButton1: TRadioButton; RadioButton2: TRadioButton; RadioButton3: TRadioButton; procedure Button1Click(Sender: TObject); procedure FormCreate(Sender: TObject);
private public end;
var Form1: TForm1; zahl: array of integer; k,i,n: integer; starttime,endtime:longint;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject); var i,p:integer;
Procedure vertausche(var x,y: integer); var hilf: integer; begin hilf:=x; x:= y; y:=hilf end;
begin memo1.Clear; memo2.clear; n := strtoint(edit1.text); setlength(Zahl,n);
If RadioButton1.Checked = True then for i:= 0 to n-1 do begin zahl[i] := 1+Random(n); form1.Memo1.lines.add(InttoStr(zahl[i])); end; If RadioButton1.Checked = True then starttime:= GetTickCount; for i:= 0 to n-1 do begin for p := (i+1)to n-1 do If RadioButton1.Checked = True then if zahl[i] > zahl[p] then Vertausche (zahl[i],zahl[p]); Form1.Memo2.lines.add(inttostr(zahl[i])) ; endtime:=GetTickCount; Label1.Caption:= InttoStr(endtime-starttime)+'ms'; end;
If RadioButton2.Checked = True then for i:= 0 to n-1 do begin zahl[i] := 1+Random(n); form1.Memo1.lines.add(InttoStr(zahl[i])); end; If RadioButton2.Checked = True then starttime:= GetTickCount; for i:= 0 to n-1 do begin for p := (i+1)to n-1 do If RadioButton2.Checked = True then if zahl[i] > zahl[p] then Vertausche (zahl[i],zahl[p]); Form1.Memo2.lines.add(inttostr(zahl[i])) ; endtime:=GetTickCount; Label1.Caption:= InttoStr(endtime-starttime)+'ms'; end;
If RadioButton3.Checked = True then for i:= 0 to n-1 do begin zahl[i] := 1+Random(n); form1.Memo1.lines.add(InttoStr(zahl[i])); end; If RadioButton3.Checked = True then starttime:= GetTickCount; for i:= 0 to n-1 do begin for p := (i+1)to n-1 do If RadioButton3.Checked = True then if zahl[i] > zahl[p] then Vertausche (zahl[i],zahl[p]); Form1.Memo2.lines.add(inttostr(zahl[i])) ; endtime:=GetTickCount; Label1.Caption:= InttoStr(endtime-starttime)+'ms'; end;
end;
procedure TForm1.FormCreate(Sender: TObject); begin memo1.Clear; memo2.clear; end;
end. |