/*
* type_combined.c
*/
#include <time.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "getputch.h"
#define NO 3 /* 训练次数 */
#define KTYPE 16 /* 块数 */
#define POS_LEN 10 /* 用于位置训练的字符数量 */
/*--- 练习菜单 ---*/
typedef enum { Term, KeyPos, KeyPosComp, Clang, Conversation, InValid } Menu;
/*--- 各个块的键 ---*/
char *kstr[] = {"12345", "67890-=",
"!@#$%", "^&*()_+",
"qlert", "yuiop[]\",
"QWERT", "YUIOP{}|",
"asdfg", "hjkl;'",
"ASDFG", "HJKL:""
"zxcvb", "nm,./",
"ZXCVB", "NM<>?",
};
/*--- C语言的关键字和库函数 ---*/
char *cstr[] = {
"auto", "break", "case", "char", "const", "continue",
"default", "do", "double", "else", "enum", "extern",
"float", "for", "goto", "if", "int", "long",
"register", "return", "short", "signed", "sizeof", "static",
"struct", "switch", "typedef", "union", "unsigned", "void",
"volatile", "while",
"abort", "abs", "acos", "asctime", "asin", "assert",
"atan", "atan2", "atexit", "atof", "atoi", "atol",
"bsearch", "calloc", "ceil", "clearerr", "clock", "cos",
"cosh", "ctime", "difftime", "div", "exit", "exp",
"fabs", "fclose", "feof", "ferror", "fflush", "fgetc",
"fgetpos", "fgets", "floor", "fmod", "fopen", "fprintf",
"fputc", "fputs", "fread", "free", "freopen", "frexp",
"fscanf", "fseek", "fsetpos", "ftell", "fwrite", "getc",
"getchar", "getenv", "gets", "gmtime", "isalnum", "isalpha",
"iscntrl", "isdigit", "isgraph", "islower", "isprint", "ispunct",
"isspace", "isupper", "isxdigit", "labs", "ldexp", "ldiv",
"localeconv", "localtime","log", "log10", "longjmp",
"malloc", "memchr", "memcmp", "memcpy", "memmove", "memset",
"mktime", "modf", "perror", "pow", "printf", "putc",
"putchar", "puts", "qsort", "raise", "rand", "realloc",
"remove", "rename", "rewind", "scanf", "setbuf", "setjmp",
"setlocale","setvbuf", "signal", "sin", "sinh", "sprintf",
"sqrt", "srand", "sscanf", "strcat", "strchr", "strcmp",
"strcoll", "strcpy", "strcspn", "strerror", "strftime", "strlen",
"strncat", "strncmp", "strncpy", "strpbrk", "strrchr", "strspn",
"strstr", "strtod", "strtok", "strtol", "strtoul", "strxfrm",
"system", "tan", "tanh", "time", "tmpfile", "tmpnam",
"tolower", "toupper", "ungetc", "va_arg", "va_end", "va_start",
"vfprintf", "vprintf", "vsprintf"
};
/*--- 英语会话 ---*/
char *vstr[] = {
"Hello!", /* 你好。*/
"How are you?", /* 你好吗?*/
"Fine thanks.", /* 嗯,我很好。*/
"I can't complain, thanks.", /* 嗯,还行吧。*/
"How do you do?", /* 初次见面。*/
"Good bye!", /* 再见。*/
"Good morning!", /* 早上好。*/
"Good afternoon!", /* 下午好。*/
"Good evening!", /* 晚上好。*/
"See you later!", /* 再见(过会见)。*/
"Go ahead, please.", /* 您先请。*/
"Thank you.", /* 谢谢。*/
"No, thank you.", /* 不,谢谢。*/
"May I have your name?", /* 请问你叫什么名字?*/
"I'm glad to meet you.", /* 很高兴能见到你。*/
"What time is it now?", /* 请问现在是几点?*/
"It's about seven.", /* 大概7点。*/
"I must go now.", /* 我不得不走了。*/
"How much?", /* 多少钱?*/
"Where is the restroom?", /* 请问洗手间在哪里?*/
"Excuse me.", /* 抱歉(一人)。*/
"Excuse us.", /* 抱歉(两人以上)。*/
"I'm sorry.", /* 对不起。*/
"I don't know.", /* 我不知道。*/
"I have no change with me.", /* 我没带零钱。*/
"I will be back.", /* 我还会回来的。*/
"Are you going out?", /* 你要出门吗?*/
"I hope I'm not disturbing you.", /* 希望不会打搅到你。*/
"I'll offer no excuse.", /* 我没打算为自己辩解。*/
"Shall we dance?", /* 来跳舞吧。*/
"Will you do me a favor?", /* 你能帮我个忙吗?*/
"It's very unseasonable.", /* 这非常不合时节啊。*/
"You are always welcome.", /* 随时欢迎。*/
"Hold still!", /* 别动!*/
"Follow me.", /* 跟我来。*/
"Just follow my lead.", /* 跟着我做就好。*/
"To be honest with you,", /* 说真的……*/
};
Menu SelectMenu()
{
int ch;
do
{
printf("
Please select practice.
");
printf("(1)Only Single (2)Combined Position
");
printf("(3)C Language word (4)English Dialogue
");
scanf("%d", &ch);
}while(ch < Term || ch >= InValid);
return (Menu)ch;
}
int go(const char *str)
{
int i, len = strlen(str), mistakes = 0;
for (i = 0; i < len; i++)
{
printf("%s
", &str[i]);
fflush(stdout);
while(getch() != str[i])
{
mistakes++;
}
}
return mistakes;
}
void pos_training(void)
{
int i, stage, temp, line, len, qno, pno , tno, mno;
clock_t start, end;
printf("
Starting single position to practice.
");
printf("please select a block to practice.
");
printf("The First floor (1) left %-8s (2) right %-8s
", kstr[0], kstr[1]);
printf("The First floor (3) left %-8s (4) right %-8s
", kstr[4], kstr[5]);
printf("The First floor (5) left %-8s (6) right %-8s
", kstr[8], kstr[9]);
printf("The First floor (7) left %-8s (8) right %-8s
", kstr[12], kstr[13]);
do
{
printf("number (99 is stop) : ");
scanf("%d", &temp);
if (temp == 99)
{
return;
}
}while(temp < 1 || temp > 8);
line = 4 * ((temp - 1) / 2) + (temp - 1) % 2;
printf("practice %s times %d topices.
", kstr[line], NO);
printf("Starting after entering space.
");
while(getch() != ' ')
;
tno = mno = 0;
len = strlen(kstr[line]);
start = clock();
for (stage = 0; stage < NO; stage++)
{
char str[POS_LEN + 1];
for (i = 0; i < POS_LEN; i++)
{
str[i] = kstr[line][rand() % len];
}
str[i] = '