Last active
August 29, 2015 14:01
-
-
Save kira924age/8447a81e5ab045b24f2b to your computer and use it in GitHub Desktop.
簡単なタイピングゲーム
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <time.h> | |
#include <conio.h> | |
#include <ctype.h> | |
#include <stdio.h> | |
#include <string.h> | |
#define Qnumber 20 | |
int main(){ | |
int i, stage, miss = 0, alpsum = 0; | |
char *japanese[Qnumber] = { | |
"交わした約束忘れないよ", | |
"目を閉じ確かめる", | |
"押し寄せた闇", | |
"振り払って進むよ", | |
"いつになったらなくした未来を", | |
"私ここでまた見ることできるの?", | |
"溢れ出した不安の影を", | |
"何度でも裂いて", | |
"この世界歩んでこう", | |
"とめどなく刻まれた", | |
"時は今始まり告げ", | |
"変わらない思いをのせ", | |
"閉ざされた扉開けよう", | |
"目覚めた心は走り出した", | |
"未来を描くため", | |
"難しい道で立ち止まっても", | |
"空はきれいな青さで", | |
"いつも待っててくれる", | |
"だから怖くない", | |
"もう何があっても挫けない" | |
}; | |
char *roman[Qnumber] = { | |
"kawasitayakusokuwasurenaiyo", | |
"mewotojitasikameru", | |
"osiyosetayami", | |
"huriharattesusumuyo", | |
"ituninattaranakusitamiraiwo", | |
"watasikokodematamirukotodekiruno", | |
"ahuredasitahuannnokagewo", | |
"nandodemosaite", | |
"konosekaiayundekou", | |
"tomedonakukizamareta", | |
"tokihaimahajimarituge", | |
"kawaranaiomoiwonose", | |
"tozasaretatobiraakeyou", | |
"mezametakokorohahasiridasita", | |
"miraiwoegakutame", | |
"muzukasiimitidetatidomattemo", | |
"sorahakireinaaosade", | |
"itumomattetekureru", | |
"dakarakowakunai", | |
"mounanigaattemokujikenai" | |
}; | |
double time; | |
clock_t start, end; | |
for (i = 0; i < Qnumber; i++) | |
alpsum += strlen(roman[i]); | |
printf("スペースキーで開始です。\n"); | |
while (_getch() != ' ') | |
; | |
start = clock(); | |
for (stage = 0; stage < Qnumber; stage++){ | |
printf("%s\n", japanese[stage]); | |
fflush(stdout); | |
int len = strlen(roman[stage]); | |
for (i = 0; i < len; i++){ | |
int ch; | |
do{ | |
ch = _getch(); | |
if (isprint(ch)){ | |
_putch(ch); | |
if (ch != roman[stage][i]){ | |
miss++; | |
_putch('\b'); | |
} | |
} | |
} while (ch != roman[stage][i]); | |
} | |
printf("\n"); | |
} | |
end = clock(); | |
time = (end - start) / CLOCKS_PER_SEC; | |
printf("\n%.2ftypes/sec\n%.1ftypes/min\nmiss types:%d\n", alpsum / time, alpsum / time * 60,miss); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment