/*
* 利用random類,結合timer控制項,設計窗體。在窗體上的文字框中顯示乙個大寫字元,如果使用者輸入正確,則產生另乙個大寫字元。
* 選單命令組成:
* (1)「設定」選單:開始遊戲、結束遊戲和退出遊戲。
* (2)「檢視」選單:檢視正確率和打字所用的時間。
* 提示與思考:
* (1)判斷輸入字元正確與否,採用哪個控制項的哪個事件;
* (2)首先考慮如何實現乙個靜止的字元(不移動)的輸入判斷;然後考慮如何讓字元動起來;
* (3)如果字元移出窗體邊界,仍然沒有輸入正確,如何讓該字元重新出現在窗體的頂端某處。
*/using system;
using system.collections.generic;
using system.componentmodel;
using system.data;
using system.drawing;
using system.linq;
using system.text;
using system.windows.forms;
private int x=200,y,num;
private datetime dt1,dt2;
private int count=0; //打字總數
private int count1=0; //打字正確數
private timespan ts;
random rd = new random();
private void form1_load(object sender, eventargs e)
private void button1_click(object sender, eventargs e) //開始按鈕
private void button2_click(object sender, eventargs e) //結束按鈕
private void button3_click(object sender, eventargs e) //退出按鈕
private void 開始遊戲toolstripmenuitem_click(object sender, eventargs e)
private void 結束遊戲toolstripmenuitem_click(object sender, eventargs e)
private void 退出遊戲toolstripmenuitem_click(object sender, eventargs e)
private void 正確率toolstripmenuitem_click(object sender, eventargs e)
", truerate);
messagebox.show("正確率為:" +s, "正確率");
}private void 所用時間toolstripmenuitem_click(object sender, eventargs e)
private void timer1_tick(object sender, eventargs e)
private void timer2_tick(object sender, eventargs e)
private void button1_keydown(object sender, keyeventargs e)
}label6.visible = true;
label8.visible = true;
label4.text = count1.tostring();
label5.text = (count - count1).tostring();
string t = string.format("", count1 * 1.0 / count);
label6.text = t.tostring();
}
}}
c 打字遊戲
include include include include include using namespace std 隨機生成數字 大寫字母 小寫字母 char randomchar if type 1 return rand 26 a 將游標移到控制台 x,y 處。void gotoxy int...
打字遊戲 摘
include stdio.h include stdlib.h include time.h void main for i 0 i90 p i j p i 0 printf s n p getchar start time clock for i 0 iend time clock a floa...
打字小遊戲
呵呵,這是我人生的第乙個寫的程式 打字遊戲!其實並不難 include include include include include using namespace std 隨機生成數字 大寫字母 小寫字母 char randomchar if type 1 return rand 26 a 將游...