Liebe pascal Benutzer
Noch eine Anfängerfrage
ich bräuchte in meinem program drei zufallszahlen
die erste zufallszahl wäre eine ganzzahl zwischen 0..9
zweite zufallszahl sollte zwischen 3 und xmax-2 und die
dritte zufallszahl sollte zwischen 3 und ymax-2 liegen
ich habe versucht das problem wie folgt zu lösen:
Google:
Dear Pascal users
Still a beginner question
I would need three random numbers in my program
The first random number would be an integer between 0..9
second random number should be between 3 and xmax-2 and the
third random number should be between 3 and YMAX-2
I tried to solve the problem as follows:
const xmax=100,ymax=30;
var aktuellezahl,zaehlerzahl,xzufall,yzufall : integer;
matrix:array[1..xmax,1..ymax] of char;
procedure zufall;
var l:longint;
begin
if aktuellezahl = zaehlerzahl then
begin
repeat
l:=random(l);
until l in [1..9];
aktuellezahl := l;
repeat
l:=random(l);
until l in [3..xmax-2];
xzufall := l;
repeat
l:=random(l);
until l in [3..ymax-2];
yzufall:=l;
zaehlerzahl := 0;
matrix[xzufall,yzufall] := chr(aktuellezahl);
Gotoxy(xzufall,yzufall);
write(aktuellezahl);
end;
end;
Problem: Bei jedem Programmaufruf liefert die function random
jedesmal die gleiche Zufallszahl.
Wer weiss Rat? Vielen Dank im voraus.
lg Thomas
Google:
Problem: For each program call, the FUNCTION RANDOM delivers
Each time the same random number.
Who knows advice? Thanks in advance.
LG Thomas
[Bitte geben Sie in diesen englischen Foren eine englische Übersetzung an.]