剛剛安霆要我寫的樂透猜碼程式~~
隨機從1-64裡取出6個數字 不重複
唉再次體驗到寫程式的最大麻煩~~不是想法 是除錯
除了整整4個小時 有興趣可以看看喔 ~~~
<script>
var m=1
var tests=new Array()
tests[0]=0
for(i=0;i<6;i++)
{
for(k=1;m!=-1;k++)
{
x=Math.random() /*隨機取0 ~1之間的數 */
x=x*64
x=x+1
y=parseInt(x)
tests[i+1]=y
for(j=0;j<i+1;j++)
{
if(tests[i+1]==tests[j])
{
x=Math.random()
x=x*64
x=x+1
y=parseInt(x)
tests[i+1]=y
j=0
}
if(j==i)
{
m=-1
}
}
}
m=1
tests[i+1]=y
}
document.write("<br>")
document.write(tests[1])
document.write("-")
document.write(tests[2])
document.write("-")
document.write(tests[3])
document.write("-")
document.write(tests[4])
document.write("-")
document.write(tests[5])
document.write("-")
document.write(tests[6])
</script>
--
我喜歡做我想做的事
但是如果我沒有機會
我會試著去喜歡上我現在在做的事
~~~~我的哲學 ==> 生活以享受為最高目的
--
※ 發信站: 批踢踢實業坊(ptt.csie.ntu.edu.tw)
◆ From: 61.59.239.215
推
推140.112.169.211 01/15, , 1F
推140.112.169.211 01/15, 1F
推
推140.112.250.233 01/15, , 2F
推140.112.250.233 01/15, 2F
推
推 61.59.239.215 01/15, , 3F
推 61.59.239.215 01/15, 3F
推
推140.112.250.233 01/15, , 4F
推140.112.250.233 01/15, 4F
推
推 61.59.239.215 01/15, , 5F
推 61.59.239.215 01/15, 5F
推
推 218.160.7.79 01/15, , 6F
推 218.160.7.79 01/15, 6F
推
推 202.178.164.58 01/15, , 7F
推 202.178.164.58 01/15, 7F
討論串 (同標題文章)
完整討論串 (本文為第 1 之 2 篇):