Autor Beitrag
-delphin-
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 200



BeitragVerfasst: Sa 17.09.05 12:47 
Hallo Forum, mein Problem ist relativ simpel, ich würde gerne Zufallszahlen erzeugen, die in einem Memo ausgegeben werden, jedoch muss jede verschieden sein, da sie später mit Bubblesort sortiert werden sollen.
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
procedure TForm1.Button1Click(Sender: TObject);
var i, border: integer;
begin
  border := SpinEdit2.Value;
  Setlength(Zahlenfeld, border);
  randomize;
  Memo1.Clear;
  for i := 1 to SpinEdit1.Value do
  begin
    Memo1.Lines.Add(IntToStr(random(border)+1));
  end;
end;


Zahlenfeld ist mein dynamischer Array, mir fehlt nur noch eine Überprüfung, dass random(border)+1 noch nicht im Memo vertreten sein darf.

Thx 4 help :D
delfiphan
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2684
Erhaltene Danke: 32



BeitragVerfasst: Sa 17.09.05 13:41 
-delphin- Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 200



BeitragVerfasst: Sa 17.09.05 17:21 
das hilft mir irgendwie nicht wirklich, leider.. wenn ichs so mache wie dort, dann klappt es nicht!
starsurfer
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 334

Win 95, Win 98, Win XP, Win Vista, Linux
D5 Enterprise ,D2005, D6 Personal, Visual C++ Express 2005, C++ Builder 6 E, Dev-C++
BeitragVerfasst: Sa 17.09.05 17:24 
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
procedure TForm1.Button1Click(Sender: TObject);  
var zahl:integer;  
    sl:tstringlist;  
begin  
randomize;  
sl:=tstringlist.Create;  
for zahl:=0 to 100 do  
  begin  
  sl.Insert(random(sl.count),inttostr(zahl));  
  end;  
memo1.lines:=sl;  
end;


erzeugt 0..100 und bringt die durcheinander

so?

_________________
GEIZ IST GEIL! - Ihr Sozialamt