⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 一个练习打字的程序.txt

📁 各种经典的C算法和特别用途C程序的源码集以供各位高级C编程研习者参考。
💻 TXT
字号:
 下面是以练习打字的程序 

主要是练习函数:window(……),textmode(……)等的使用 

只支持26字母的练习 

#include "stdio.h"
#include "time.h"
#include "conio.h"
#include "dos.h"
#define BGCOLOR BLUE
#define FORECOLOR GREEN
#define WIDTH 80
#define HEIGHT 25 

int Row=0;
int Corrects=0;
int Hits=0;
int Errors=0;
char SrcList[2*WIDTH]={'\0'}; 

void InitTextMode()
{
textmode(2);
textbackground(BGCOLOR);
textcolor(FORECOLOR);
} 

void DrawFrame()
{
textmode(2);
window(1,1,80,3);
textbackground(FORECOLOR);
textcolor(BGCOLOR);
clrscr();
printf("\nHits: %d\tCorrects: %d\tErrors: %d",Hits,Corrects,Errors);
window(1,4,80,25);
textcolor(FORECOLOR);
textbackground(BGCOLOR);
clrscr();
} 

void ShowSplash()
{
clrscr();
gotoxy(30,11);
printf("Welcome To Use This Software!");
gotoxy(50,13);
printf("Maker:cangzhu.");
getch();
clrscr();
} 

void ShowSample()
{
int i;
srand(time(0));
for(i=0;i<WIDTH;i+=2)
{
 SrcList[i]=rand()%26+'A';
 SrcList[i+1]=' ';
}
gotoxy(1,Row*3+1);
printf("%s",SrcList);
} 

void UpdateResult()
{
window(1,1,80,3);
textbackground(FORECOLOR);
textcolor(BGCOLOR);
clrscr();
printf("\nHits: %d\tCorrects: %d\tErrors: %d",Hits,Corrects,Errors);
window(1,4,80,25);
} 

void main()
{
char ch;
int i=0;
InitTextMode();
ShowSplash();
DrawFrame();
ShowSample();
while(1)
{
 ch=getch();
 if(ch==27)
   exit(0);
 if(ch>='a'&&ch<='z')
   ch-=32;
 if(!(ch>='A'&&ch<='Z'))
   continue;
 Hits++;
 if(ch==SrcList[i])
 {
  printf("%c ",ch);
  i+=2;
  Corrects++;
  if(i>=80)
  {
   Row++;
   if(Row>=7)
     Row=0;
   ShowSample();
   i=0;
  }
  UpdateResult();
 }
 else
 {
  sound(2000);
  delay(50000);
  nosound();
  Errors++;
  UpdateResult();
 }
 gotoxy(i+1,3*Row+2);
}
} 
 
 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -