Autor Beitrag
TomZ
Hält's aus hier
Beiträge: 13


D8 Pers, FreePascal
BeitragVerfasst: So 21.08.05 16:10 
Hallo,

ich hoffe Ihr versteht was ich meine ... ;-)

Ich bräuchte eine Liste (16 Stück) von per Zufall durcbeinander gewürfelte Integer-Werte ... also so in etwa:

3
6
1
9
2
...

Gibts da 'ne fertige Funktion für??
WeBsPaCe
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 2322
Erhaltene Danke: 1

FireFox 3, Internet Explorer 6 SP1
D1, D3Prof, D6Pers, D7Pers+Indy, VisualStudio Express
BeitragVerfasst: So 21.08.05 16:18 
Einfach mal die Suche benutzen oder in die OnlineHilfe schauen. ;)
Suche in: Delphi-Forum, Delphi-Library RANDOM und Suche in: Delphi-Forum, Delphi-Library RANDOMIZE

slt, WeBBy
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: So 21.08.05 16:20 
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 15 do
begin
sl.Insert(random(sl.count),inttostr(zahl));
end;
memo1.lines:=sl;
end;


so :wink:

_________________
GEIZ IST GEIL! - Ihr Sozialamt
TomZ Threadstarter
Hält's aus hier
Beiträge: 13


D8 Pers, FreePascal
BeitragVerfasst: So 21.08.05 16:58 
user profile iconstarsurfer hat folgendes geschrieben:
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 15 do
begin
sl.Insert(random(sl.count),inttostr(zahl));
end;
memo1.lines:=sl;
end;


so :wink:


Danke - dann hab ich aber immer noch u.U. Zahlen doppelt, jede Zahl darf aber nur einmal vorkommen ...
WeBsPaCe
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 2322
Erhaltene Danke: 1

FireFox 3, Internet Explorer 6 SP1
D1, D3Prof, D6Pers, D7Pers+Indy, VisualStudio Express
BeitragVerfasst: So 21.08.05 17:02 
Einfach ein Array aufmachen mit den Zahlen, die noch als Möglichkeiten zur Verfügung stehen. Wenn die Zahl "gezogen" wurde, den Array-Eintrag löschen. ;)
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: So 21.08.05 17:04 
mmmh? bei mir kommt da keine zahl doppelt raus,

wie auch?

ausblenden Delphi-Quelltext
1:
for zahl:=0 to 15 do					


zählt ja einfach nur rauf...

_________________
GEIZ IST GEIL! - Ihr Sozialamt
WeBsPaCe
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 2322
Erhaltene Danke: 1

FireFox 3, Internet Explorer 6 SP1
D1, D3Prof, D6Pers, D7Pers+Indy, VisualStudio Express
BeitragVerfasst: So 21.08.05 17:14 
Was ist, wenn dein random() dir irgendwann eine Zahl ausspuckt, die du schonmal hattest? ;)
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: So 21.08.05 17:20 
das Random() is nur für de position in der stringliste verantwortlich,

hat meine stringliste Bsp: 2 zeilen;

ausblenden Quelltext
1:
2:
zeile1
zeile2


und random ermittelt 2 dann:

ausblenden Quelltext
1:
2:
3:
zeile1
neu dazu
zeile2


siehts so aus, die aktuelle zeile 2 wird halt durch "neu dazu" ersetzt und wird zur neuen Zeile 3
:D

_________________
GEIZ IST GEIL! - Ihr Sozialamt
WeBsPaCe
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 2322
Erhaltene Danke: 1

FireFox 3, Internet Explorer 6 SP1
D1, D3Prof, D6Pers, D7Pers+Indy, VisualStudio Express
BeitragVerfasst: So 21.08.05 17:31 
Omg... :oops: Hab deinen Code falsch verstanden. Ich dachte, du machst es so wie ich gedacht habe. :lol: Sorry... ;)
TomZ Threadstarter
Hält's aus hier
Beiträge: 13


D8 Pers, FreePascal
BeitragVerfasst: So 21.08.05 21:19 
Danke schön, ich habs hinbekommen!!!