當前位置:遊戲中心平台 - 遊戲大全 - 使用變量和函數,設計和模擬幸運數字機遊戲。

使用變量和函數,設計和模擬幸運數字機遊戲。

& lt!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN " " " & gt;

& lthtml & gt

& lthead & gt

& lttitle & gt在此插入標題& lt/title & gt;

& lt腳本語言= " javascript " & gt

函數aa() {

var m = 0;

var n = 0;

做{

var a = math . floor(math . random()* 9+1);

var b = math . floor(math . random()* 9+1);

var c = math . floor(math . random()* 9+1);

var str =字符串(a) +字符串(b) +字符串(c);

if (a == 8 || b == 8 || c == 8) {

m++;

flag = true

}否則{

flag = false

n++;

}

if (flag == true) {

V = confirm (str+"\ nWin \n"+"勝率"

+(math . floor((m/(m+n))* 100))+" %,"+"要繼續嗎?");

}

if (flag == false) {

V = confirm (str+"\ nLose \n"+"勝率"

+(math . floor((m/(m+n))* 100))+" %,"+"要繼續嗎?");

}

} while (v)

}

& lt/script & gt;

& lt/head & gt;

& ltbody bgcolor="pink " >

使用變量和函數,設計和模擬幸運數字機遊戲。設幸運數字為8,電腦每次會隨機產生三個1~9(包括1和9)的隨機數。當三個隨機數中有壹個是8時,妳將贏得壹次。要求使用函數計算勝率。

& ltbr/>;

& ltinput type = " button " name = " " onclick = " aa()" value = " lottery "/& gt;

& lt/body & gt;

& lt/html & gt;

  • 上一篇:模擬人生浪漫相待任務怎麽解鎖
  • 下一篇:英超中場休息可以換幾次球員?
  • copyright 2024遊戲中心平台