怎么为产生随机序列播种? |
尚未結案
|
小丫123
初階會員 發表:85 回覆:62 積分:29 註冊:2004-08-31 發送簡訊給我 |
1。我看到有这样一个程序:
procedure initialize(seed:integer) begin seed:=random(100); end我觉得不太对我觉得应该是: procedure initialize(seed:integer) begin random(seed); end不知道我这么想对不对 2。在C语言中,有这么一段程序 time_t t; initialize ((unsigned)time(&t));不知道在delphi中应该怎么实现? 恳请各大delphi高手指点!!! |
Fishman
尊榮會員 發表:120 回覆:1949 積分:2163 註冊:2006-10-28 發送簡訊給我 |
Hi 小丫123,
procedure TForm1.Button1Click(Sender: TObject); var R : Integer; begin Randomize; R := Random(100); Edit1.Text := IntToStr(R); end;Randomize procedure : Initializes the random number generator with a random value. Random function : Generates random numbers within a specified range. In Delphi code, Random returns a random number within the range 0 <= X < Range. If Range is not specified, the result is a real-type random number within the range 0 <= X < 1. For more detail information, see Delphi help document. ---------------------------------- 小弟才疏學淺,若有謬誤尚請不吝指教 ----------------------------------
------
Fishman |
wameng
版主 發表:31 回覆:1336 積分:1188 註冊:2004-09-16 發送簡訊給我 |
|
richtop
資深會員 發表:122 回覆:646 積分:468 註冊:2003-06-10 發送簡訊給我 |
本站聲明 |
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。 2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。 3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇! |