Autor Beitrag
altonasurfer
Hält's aus hier
Beiträge: 11



BeitragVerfasst: Sa 19.11.05 14:08 
Ich willt ein Program schreiben, dass die Ziehung der Lottozahlen simuliert. Die Zahlen sollen in Panel Komponenten ausgegeben werden. So sieht mein Porgramm bisher aus. Das Problem ist, das ich die Felder nicht sortiert bekomme.





ausblenden volle Höhe Delphi-Quelltext
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:
procedure TForm1.Button1Click(Sender: TObject);
Var a: Array[1..6of integer;
j,hilfsvar,min,i: byte;
begin
panel1.caption:='';
panel2.caption:='';
panel3.caption:='';
panel4.caption:='';
panel5.caption:='';
panel6.caption:='';
randomize;
For i:=1 to 6 do
begin
repeat
a[i]:= random(50);
until (a[i]>0and (a[i]<>a[i-1]) and (a[i]<>a[i-2]) and (a[i]<>a[i-3]) and (a[i]<>a[i-4])and (a[i]<>a[i-5]) and (a[i]<>a[i-6]);
end;
for i:=1 to 5 do begin
min:=i;
For j:=i+1 to 6 do
if a[j]<min then min:=j;
hilfsvar:=a[min];
a[min]:=a[i];
a[i]:=hilfsvar;
end;
panel1.Caption:= inttostr(a[1]);
delay(1000);
panel2.Caption:= inttostr(a[2]);
delay(1000);
panel3.Caption:= inttostr(a[3]);
delay(1000);
panel4.Caption:= inttostr(a[4]);
delay(1000);
panel5.Caption:= inttostr(a[5]);
delay(1000);
panel6.Caption:= inttostr(a[6]);
delay(1000);
end;
end.


Moderiert von user profile iconChristian S.: Delphi-Tags hinzugefügt
Moderiert von user profile iconTino: Topic aus Delphi Language (Object-Pascal) / CLX verschoben am Fr 25.11.2005 um 11:09
Narses
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Administrator
Beiträge: 10183
Erhaltene Danke: 1256

W10ent
TP3 .. D7pro .. D10.2CE
BeitragVerfasst: Sa 19.11.05 15:54 
Moin und :welcome: im Forum!

Du kannst auch die Suchfunktion benutzen, um Beiträge zu finden, die dir helfen könnten; und Sortieren ist ja jetzt nicht gerade erst Gestern erfunden worden... :wink: Hätte dich ja vielleicht zu diesem Beitrag gebracht, in dem das Sortierverfahren BubbleSort erläutert wird.

cu
Narses