Created
September 27, 2019 06:27
-
-
Save mrgarita/6be8111c531f25e989974bc6209551f9 to your computer and use it in GitHub Desktop.
C言語:clock関数を使ってキーボードのA~Zまでの入力速度を測るプログラム
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
/* xOtokuuti お特打ち(キーボード練習っぽいプログラム) */ | |
#include <stdio.h> | |
#include <string.h> | |
#include <time.h> | |
int main(void) | |
{ | |
long start, end; | |
double total_time ; | |
char tokuuchi[] = "abcdefghijklmnopqrstuvwxyz" ; /* 入力する文字列 */ | |
char in[100] ; | |
/* 特打開始 */ | |
printf("\n\n【ミッション】以下の文字を入力せよ! 目標: 12.000 sec\n") ; | |
printf(" ↓ ↓ ↓ ↓ ↓ ↓ エンターキーで開始!\n") ; | |
printf(" %s", tokuuchi ) ; | |
getchar(); | |
/* タイマー開始 */ | |
start = clock(); | |
printf(" >"); | |
scanf("%s", in ) ; | |
/* タイマー終了 */ | |
end = clock(); | |
/* 打ち込みに掛かった時間を計算(秒に直す) */ | |
total_time = (double)(end - start) / CLOCKS_PER_SEC ; | |
printf("\n\n") ; /* 見やすいように改行 */ | |
/* 正確に打てたか判定する */ | |
if ( !( strcmp ( in, tokuuchi ) ) ) { | |
printf("ミッションクリア!\nTOTAL TIME = %10lf sec\n", total_time ) ; | |
/* 打ち込み時間により判定 */ | |
if ( total_time > 16.0 ) { | |
printf("はっ!さっきおまえの指にトンボが止まってたぜ!【へなちょこ打ち】\n\n") ; | |
} | |
else if ( total_time > 12.0 ) { | |
printf("まあまあってとこだなっ!【並打ち】\n\n") ; | |
} | |
else if ( total_time > 11.0 ) { | |
printf("やるじゃねえかっ!目標値クリアだ!【特打ち】\n\n") ; | |
} | |
else if ( total_time > 9.0 ) { | |
printf("おまえの指、見えなかったぜ!【激打ち】\n\n") ; | |
} | |
else { | |
printf("うわあぁぁぁーー。にっ人間じゃねぇー【無想転生】\n\n") ; | |
} | |
} | |
else { | |
printf("おいっ、間違ってるじゃねえか。もうくるんじゃねぇ!!\n\n") ; | |
} | |
rewind(stdin); /* scanfの誤動作対策 */ | |
puts("Push any key..............."); | |
getchar(); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment