最近中文字幕高清中文字幕无,亚洲欧美高清一区二区三区,一本色道无码道dvd在线观看 ,一个人看的www免费高清中文字幕

為了賬號安全,請及時綁定郵箱和手機立即綁定

怎么實現(xiàn)生成一個隨機整數(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之間的隨機整數(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 提問者

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

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

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

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

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

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

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

慕虎3994276 提問者

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

舉報

0/150
提交
取消

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

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

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

幫助反饋 APP下載

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

公眾號

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