跳到正文

休闲·娱乐

C++打字游戏

cxk_ctrl约 3 分钟
原文
文章信息与版本

文章信息

发布
2024年10月2日
收录
2025年12月12日
更新
2026年9月18日
篇幅
约 3 分钟
获赞
2

版本

  1. v1当前

牢大打字通

  • [2024/10/2]1.0版本

  • [2024/10/3]1.1版本:加入连续打对计数、修复错题集bug

更新预告

预计下次更新:暂咕

  • 重新排版代码,增加可读性

  • 添加更多打字功能(例如数字、短语)

C++
#include<bits/stdc++.h>
#include<windows.h>
#include<cstdio>
#include<conio.h>
using namespace std;
int random(int low, int high)
{
    return low + rand() % (high - low + 1);
}
char worng[1145];
int cz=0;
int main()
{
	srand(time(NULL));
    char out;
    char zj;
    char in;
    int conyes=0; 
    while(1)
    {
    	system("cls");
    	cout<<"注意: 开始后输入1退出, 字母都是大写的"<<endl;
    	cout<<"1-start"<<endl;
    	cout<<"2-worng"<<endl;
    	Sleep(20);
    	in=getch();
    	if(in=='1')
    	{
    		while(1)
   			{
    			system("cls");
    			out=random(65, 90);
    			zj=out;
    			cout<<"已经连续打对"<<conyes<<endl;
    			cout<<out;
    			in=getch();
    			if(in==out)
    			{
    				conyes++;
	    			continue;
				}
				else if(in=='1')
				{
					conyes=0;
					break;
				}
				else
				{
					conyes=0;
					system("cls");
					cout<<"你错了";
					worng[cz]=out;
					cz++;
					Sleep(1000);
				}	
			}
		}
		else if(in=='2')
		{
			int sum=0;
			while(sum < cz)
			{
				system("cls");
				cout<<worng[sum];
				in=getch();
				if(in==worng[sum])
				{
					for (int i = sum; i < cz - 1; i++) {
                        worng[i] = worng[i + 1];
                    }
                    cz--;
                    continue;
				}
				else if(in=='1')
				{
					break;
				}
				else
				{
					system("cls");
					cout<<"你错了";
					Sleep(1000);
				}
			}
			system("cls");
		}
		continue;
	}
}
原文
存档评论2 条抓取于