第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定

怎么實(shí)現(xiàn)生成一個(gè)隨機(jī)整數(shù)?

<!DOCTYPE html>

<html>

<head>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<title>Math </title>

<script type="text/javascript">

var x;

x = document.write(Math.random());

document.write(Math.round(x));

</script>

</head>

<body>

</body>

</html>



正在回答

3 回答

var?a=Math.round(Math.random()*10);

上面這行代碼就生成1到10之間的隨機(jī)整數(shù)

0 回復(fù) 有任何疑惑可以回復(fù)我~
#1

Heron_Wang

0到10
2018-08-13 回復(fù) 有任何疑惑可以回復(fù)我~

document.write(Math.round((Math.random())*10));

0 回復(fù) 有任何疑惑可以回復(fù)我~
#1

慕虎3994276 提問(wèn)者

謝謝 我去試試!
2018-08-25 回復(fù) 有任何疑惑可以回復(fù)我~

Math.random();是隨機(jī)0~1之間的數(shù);

Math.random()*10;隨機(jī)1~10之間的數(shù);

Math.round(Math.random()*10); 隨機(jī)1~10之間的整數(shù);

//random()隨機(jī)數(shù);

//round()四舍五入為整數(shù);

0 回復(fù) 有任何疑惑可以回復(fù)我~
#1

慕虎3994276 提問(wèn)者

謝謝 我去試試!
2018-08-25 回復(fù) 有任何疑惑可以回復(fù)我~

舉報(bào)

0/150
提交
取消

怎么實(shí)現(xiàn)生成一個(gè)隨機(jī)整數(shù)?

我要回答 關(guān)注問(wèn)題
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)