闪电练打字,一个练打字的小程序。
纯源码开发。
无需联网。
里面的单词都会有一个独立的单词库。
在Dev-C++里面新建源文件,然后将以下代码粘贴并运行:
#include<bits/stdc++.h>
#include<conio.h>
#include<stdio.h>
#include<windows.h>
using namespace std;
long long do_sum;
string User_name;
int learn_sum;
string PIN="OUQId0<>+=h!~&FSDRGgythtde-";
string tmp;
string word_2[1000]={"car","dog","mine","yours","can","do","man","woman","us","out","hello","apple","orange","watermelon","banana","long","short","juice","milk","at","only","book","store","science","Chinese","math","English","Japan","letter","next","usually","also","always","down","up","in","near","me","gun","computer","key","board","pencil","phone","mouse","eyes","ears","teeth","blue","red","is","am","are"};
string word_1[1000]={"th","ar","or","ty","pr","re","dr","tr","ck","cl","ea","ee","ou","le","er","ng","sh","ch","ai","sk","ve","ke","en","an","ir","ow","op","se","lp","ss","sn","bl","sp","st","sc","ie","ion","me","gh","au","ry","sw","oo","ten","to","dio","ce","xt","cl","fr","nn"};
string word_3[1000]={};
void dd(double a) {
Sleep(a*1000);
}
bool key_f;
void UI() {
system("color F9");
cout<<"Lightning KeyBoard 闪电打字\n------------------------\n注意:请不要开大写,词组库还未向用户开放";
cout<<User_name<<",你的当前练习单词数量:"<<learn_sum<<",加油!\n";
cout<<"按下Q退出\n";
cout<<"按下S开始练习打字";
}
bool Login() {
dd(0.5);
cout<<"请输入通用产品密钥(可能在主程序的文件目录下):";
cin>>tmp;
dd(0.1);
if(tmp==PIN){
cout<<"密钥正确Ture!\n";
dd(0.3);
cout<<"请输入你的用户名:";
cin>>User_name;
}
else {
cout<<"发生了错误,可能是输入错误,也可能是密钥错误False";
dd(0.1);
key_f=1;
}
system("cls");
}
int ran(int kk) {
int RanddomNumber;
srand((unsigned)time(NULL));//time()用系统时间初始化种。为rand()生成不同的随机种子。
RanddomNumber = rand() % kk + 1;//生成1~100随机数
return RanddomNumber;
}
void K_() {
system("cls");
cout<<"请输入词根1/单词2/词组3库编号:";
int t;
scanf("%d",&t);
int nu;
if(t==1){
system("cls");
cout<<"当前是词根库,准备好了吗?(按下任意键以开始)" ;
int num = 0;
int no=0;
char rr=getch();
system("cls");
for (int i = 1;i <= 30;i++) {
int in=ran(50);
num++;
cout<<"-----------------------\n已练习数量:"<<num<<",错误数量:"<<no<<",本次练习总数量:30\n";
cout<<"词根:";
cout<<word_1[in]<<" | ";
cin>>tmp;
learn_sum++;
if(tmp=="quit")break;
if(tmp!=word_1[in])no++;
nu++;
if(nu==3){
system("cls");
cout<<"如果要退出,请输入quit\n";
nu=0;
}
}
system("cls");
cout<<"练习完成!\n";
cout<<"本次练习结果:错误:"<<no<<"处";
} else if(t==2){
system("cls");
cout<<"当前是单词库,准备好了吗?(按下任意键以开始)" ;
int num = 0;
int no=0;
char rr=getch();
system("cls");
for (int i = 1;i <= 30;i++) {
int in=ran(50);
num++;
cout<<"-----------------------\n已练习数量:"<<num<<",错误数量:"<<no<<",本次练习总数量:30\n";
cout<<"单词:";
cout<<word_2[in]<<" | ";
cin>>tmp;
learn_sum++;
if(tmp=="quit")break;
if(tmp!=word_2[in])no++;
nu++;
if(nu==3){
system("cls");
cout<<"如果要退出,请输入quit\n";
nu=0;
}
}
system("cls");
cout<<"练习完成!\n";
cout<<"本次练习结果:错误:"<<no<<"处";
} else {
system("cls");
cout<<"词组库当前未向普通用户开放,请升级到Pro,Ultra用户";
dd(2);
system("pause");
}
}
void hide_cursor() { //隐藏光标
HANDLE h_GAME =GetStdHandle(STD_OUTPUT_HANDLE);
CONSOLE_CURSOR_INFO cursor_info;
GetConsoleCursorInfo(h_GAME,&cursor_info);
cursor_info.bVisible=false;
SetConsoleCursorInfo(h_GAME,&cursor_info);
}
COORD get_font_size() {//
COORD font_size;
HANDLE handle = GetStdHandle(STD_OUTPUT_HANDLE);
struct CONSOLE_FONT {
DWORD index;
COORD dim;
} cfi;
typedef COORD (WINAPI *PROCGETCONSOLEFONTSIZE)(HANDLE, DWORD);
typedef BOOL (WINAPI *PROCGETCURRENTCONSOLEFONT)(HANDLE, BOOL, struct CONSOLE_FONT*);
HMODULE hKernel32 = GetModuleHandle("kernel32");
PROCGETCONSOLEFONTSIZE GetConsoleFontSize = (PROCGETCONSOLEFONTSIZE)GetProcAddress(hKernel32,"GetConsoleFontSize");
PROCGETCURRENTCONSOLEFONT GetCurrentConsoleFont = (PROCGETCURRENTCONSOLEFONT)GetProcAddress(hKernel32,"GetCurrentConsoleFont");
GetCurrentConsoleFont(handle, FALSE, &cfi);
font_size = GetConsoleFontSize(handle, cfi.index);
return font_size;
}
void ziti() {//字体
CONSOLE_FONT_INFOEX cfi;
cfi.cbSize = sizeof(cfi);
cfi.nFont = 0;
cfi.dwFontSize.X = 0;
cfi.dwFontSize.Y = 24;
cfi.FontFamily = FF_DONTCARE;
cfi.FontWeight = FW_NORMAL;
std::wcscpy(cfi.FaceName, L"Consolas");
SetCurrentConsoleFontEx(GetStdHandle(STD_OUTPUT_HANDLE), FALSE, &cfi);
}
void full_screen() {//屏幕大小
HWND hwnd = GetForegroundWindow();
HANDLE handle = GetStdHandle(STD_OUTPUT_HANDLE);
int cx = GetSystemMetrics(SM_CXSCREEN);
int cy = GetSystemMetrics(SM_CYSCREEN);
COORD size = get_font_size();
char cmd[32] = { 0 };
sprintf(cmd, "MODE CON: COLS=%d LINES=%d", cx / size.X, cy / size.Y);
system(cmd);
SetWindowPos(hwnd, HWND_TOP, 0, 0, cx, cy, 0);
}
int main (){
system("color F5");
hide_cursor();
//full_screen();
ziti();
Login();
if(key_f==1)return 0;
for (;;) {
UI();
char c=getch();
if(c=='q')dd(0.8),system("pause");
else if(c=='s'){
K_();
}
system("cls");
}
return 0;
}
密钥:OUQId0<>+=h!~&FSDRGgythtde-
关注一下吧,球求拉!!!!