求個隨機數生成器,求一個簡易的隨機數生成器,數字1 90號,謝謝啦。。

2021-03-22 08:14:01 字數 5893 閱讀 1687

1樓:匿名使用者

ramdom rd=new ramdom();//例項化random 類的新例項rd

for(int=0;i<10;i++)//for迴圈語句

次猜數:",i+1,num);//在控制檯上寫"第1次猜數:"num這裡有問題吧,猜數遊戲生成的隨機數怎麼能顯示出來?

int input;//定義一個整型變數

do//do……while迴圈當滿足while條件的時候執行

if(input>num)//判斷輸入的數和隨機產生的數,如果大了就輸出"大了";並結束本次迴圈

else if(input

else

break;

}while(input!=num);}

2樓:匿名使用者

vb中有專門生成隨機數的函式 .

給你的**,你加進去,並添上相應控制元件就行了.然後看下**就很容易明白了.謝謝.

private sub form_load()

***mand1.caption = "隨機畫圓"

***mand2.caption = "隨機文字"

***mand3.caption = "立體圖形"

***mand4.caption = "隨機影象"

***mand5.caption = "退出"

'註釋: 隨機畫圓動畫

private sub ***mand1_click()

dim xpos, ypos

picture1.cls

do nn = int(100 * rnd)

if nn > 0 then

picture1.drawwidth = nn

end if

xpos = rnd * picture1.scalewidth

ypos = rnd * picture1.scaleheight

picture1.pset (xpos, ypos), rgb(rnd * 256, rnd * 256, rnd * 256)

doevents

loop

end sub

'註釋: 隨機文字動畫

private sub ***mand2_click()

picture1.cls

do nn = int(45 * rnd)

if nn > 0 then

picture1.fontsize = nn

end if

picture1.currentx = rnd * picture1.scalewidth - 1000

picture1.currenty = rnd * picture1.scaleheight

picture1.forecolor = rgb(rnd * 256, rnd * 256, rnd * 256)

picture1.print "enjin 你個豬!"

n = n + 1

if n > 50 then

n = 0

picture1.backcolor = qbcolor(rnd * 15)

end if

doevents

loop

end sub

'註釋: 立體隨機動畫

private sub ***mand3_click()

dim m, n

picture1.drawwidth = 1

picture1.backcolor = rgb(210, 150, 0)

picture1.cls

do m = rnd * picture1.scalewidth

n = rnd * picture1.scaleheight - 500

for i = 0 to rnd * 800

picture1.line (m, n + 2.5 * i)-(m + i / 2, n + 2 * i), rgb(180, 180, 180)

picture1.line (m, n + 2.5 * i)-(m - i / 2, n + 2 * i), rgb(80, 80, 80)

next i

doevents

loop

end sub

'註釋: 隨機影象顯示

private sub ***mand4_click()

do xx = rnd * picture1.width

yy = rnd * picture1.height

picture1.paintpicture picture2.picture, xx, yy, picture2.width, picture2.height

doevents

loop

end sub

'註釋: 退出按鈕

private sub ***mand5_click()

endend sub

3樓:匿名使用者

用excel可以生成隨機數

或minitab

4樓:匿名使用者

求一個簡易的隨機數生成器,數字1-90號,謝謝啦。。

5樓:匿名使用者

應該可以用excel的rand()函式生成吧 把區間設定成1-90 就可以了

隨機數生成器

6樓:馬馬君

可驗證的**:

private m as integer, n as integer

private sub ***mand1_click()

if isnumeric(text1) = false then '位數保護

msgbox "位數必須輸入

數字"text1.setfocus

else

if val(trim(text1)) < 1 or val(trim(text1)) > 4 then

msgbox "位數是1~4的正整數"

text1 = ""

text1.setfocus

end if

end if

if isnumeric(text2) = false then '個數保護

msgbox "個數必須輸入數字"

text2.setfocus

else

if val(trim(text2)) < 1 or val(trim(text2)) > 100 then

msgbox "個數是1~100的正整數"

text2 = ""

text2.setfocus

end if

end if

text3 = ""

dim i as integer, k as integer

m = val(trim(text1))

n = val(trim(text2))

for i = 1 to n '產生n個隨機數

randomize

select case m '區別位數

case 1

k = 1 + int(rnd * 9)

case 2

k = 10 + int(rnd * 90)

case 3

k = 100 + int(rnd * 900)

case 4

k = 1000 + int(rnd * 9000)

end select

text3 = text3 & k & "," '填充文字框

next i

end sub

說明:1、設定範圍:位數<=4, 個數<=100

2、介面說明:兩個標籤、兩個普通文字框、一個按鈕、一個多行文字框text3

3、對位數和個數的輸入值,有驗證

效果如下圖。不知偶理解樓主意思沒有?

7樓:匿名使用者

隨機數生成可用rnd*a+1才完成.

dim a%, b%,

private sub timer1_timer()'窗體上加個時間控制元件,就可以在規定的間隔

a = rnd * 10 + 1 '時間產生隨機1-10的數,b是控制產生5個後退出,

print a '如果要產生兩位數的,就把10換成100,依此類推,1000,10000...

b = b + 1 '哦,我現在是看明白了,好吧,左邊的**是基礎,我就不刪了.

if b = 5 then '在窗體上加兩lable1,2和兩text1,2.不多說,text1,2分別接

end '收個數和位數.c=val(text1.text);d=val(text2.text)

end if 'val是把字元換成數字,把左邊**中10換成c,5換成d就可以

end sub '了/

8樓:匿名使用者

綠色**查下看看有沒。裡面有多軟體。

求一個簡易的隨機數生成器,數字1-50號,謝謝啦。。下午急用啊

9樓:匿名使用者

在excel中,在a1輸入

=int(rand()*50+1)

然後將公式複製到a2:a50中即可。每按一次f9功能鍵,就變一次。

10樓:匿名使用者

在a1裡面a1-a50中用公式生成50個隨機數=rand()

b1-b50中用公式排序,b1中輸入=rank(a1,$a$1:$a$50)

能不能幫我做一個隨機數生成器,每次只生成一個數就夠了

求做一個隨機數生成器flash

11樓:匿名使用者

可以做到的,以前做過。

12樓:**是

不--免費--的 要嗎?

求做一個flash的隨機數生成器

13樓:匿名使用者

恩 好的 我幫你生成 呵呵。 開啟你的flash cs3 或者flash cs4 .新建一個flash檔案(actionscript3.

0).能後名一個儲存名一個名字。能後點一下舞臺,在選擇時間軸,選第一幀 並按f9.

寫入以下**;

var tf:textfield=new textfield();

tf.background=true;

tf.backgroundcolor=0xcc00cc;

//把tf這個文字域加到顯示列表中

addchild(tf);

//做一個對鍵盤事件的偵聽

//鍵盤一按下就執行kd這個方法

stage.addeventlistener(keyboardevent.key_down,kd);

function kd(e:keyboardevent):voidok儲存 執行。

請記住 把你的flash關閉 。以為焦點會錯亂 能後 單獨 開啟那個swf就好了。你點一下 swf的舞臺讓swf 得到焦點 能後按下鍵盤做測試。

希望你能看的懂

14樓:匿名使用者

math.random()*100; //0-100之間的帶小數點的數.

math.floor(math.random()*100) //0-100之間的整數.

Excel已知平均數求兩個隨機數,且兩個隨機數需要為偶數,需要怎做

先定出第一個數,可以用2 產生的一個較小的隨機整數,就根據平均值和已知的一個隨機數來計算出第二個數是多少,以便保證平均數是確定值 在a1中輸入或複製貼上下列公式 randbetween 1,1000 在c1中輸入或複製貼上下列公式 floor randbetween 0,a2 2 2 在d1中輸入或...

vb問題 關於隨機數,一個vb問題 關於隨機數

放置一個label一個command然後把form的boarderstyle設定成3後貼上下面的 dim invalue dim arr as integer private sub command1 click 產生隨機數字 randomize dim rndnum as integerrndnu...

用excel生成1萬個不重複的隨機數

201401 5位數 10.5位數生成 1 99999 隨機數序號 結果 10.66923718 20.666948210 30.276677312 40.35952843 50.486855511 60.34990666 70.77859974 80.02875585 90.88373492 第一...