標題的針對知乎指的是,本來巴哈姆特這邊的程式已經有鍵盤與時間控制了!!
為了讓大家稍微體會一下中國古文化
因此先讓大家熟悉六十四卦
(農民曆上,除去吉凶神(路空,三合,六合...)之外
還有二十八星宿,五行,天干,地支,桂月一類的
但那些比較好背或者說是隨機抽取的數量較小
以遊戲而言還是玩六十四卦)
規則大概是 畫面會出現 乾䷀
然後玩家輸入第幾卦?
這要輸入1或01(程式設計問題)
若打錯字要怎麼處理要想下
(仔細想了下,六十四卦因為比較難猜,是否要來個提示
像是小過 距離(減去) 離卦 有多少個卦這樣)
在等我把程式寫好之前
大家可以練習寫一些程式
基礎題
利用迴圈讓網頁出現
1.
*****
*****
*****
*****
*****
2.
*
**
***
****
*****
3.
*
**
***
**
*
(其實上述三題除了迴圈、硬解出來之外
還有數學公式的解法
可參考知乎Milo Yep還是Milo Yip,總之就是葉神的過往回答)
進階題
我能不能利用無限迴圈來省去用F5(Refresh,刷新)的麻煩?
從上篇的程式碼來改
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-16"/>
</head>
<body>
<div id="div_test"></div>
<script>
function getUnicodeCharacter(cp) {
if (cp >= 0 && cp <= 0xD7FF || cp >= 0xE000 && cp <= 0xFFFF) {
return String.fromCharCode(cp);
} else if (cp >= 0x10000 && cp <= 0x10FFFF) {
// we substract 0x10000 from cp to get a 20-bits number
// in the range 0..0xFFFF
cp -= 0x10000;
// we add 0xD800 to the number formed by the first 10 bits
// to give the first byte
var first = ((0xffc00 & cp) >> 10) + 0xD800
// we add 0xDC00 to the number formed by the low 10 bits
// to give the second byte
var second = (0x3ff & cp) + 0xDC00;
return String.fromCharCode(first) + String.fromCharCode(second);
}
}
if(Math.random() > 0.5)
{
//var j=parseInt(0x2638,16);
for(var i=0x2630;i<0x2638;i++)
{
document.getElementById("div_test").innerHTML+= getUnicodeCharacter(i);
//document.write(String(i));
}
}
else
{
for(var h=0;h<8;h++)
{
for(var k=0x4DC0+h*8;k<0x4DC0+h*8+8;k++)
{
document.getElementById("div_test").innerHTML+= getUnicodeCharacter(k);
}
document.getElementById("div_test").innerHTML+="<br>"
//↑每印八個六十四卦,就換行一次
}
}
</script>
</body>
</html>