打字练习代码

合集下载

1C#打字游戏代码(初学者易懂)

1C#打字游戏代码(初学者易懂)

} } private void 退出ToolStripMenuItem_Click(object sender, EventArgs e) { if (DialogResult.Yes == MessageBox.Show(" 确 认 结 束 吗 [Y/N]", " 一 个 结 束 确 认 窗 口 ", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2)) { Application.Exit(); } } private void 提示ToolStripMenuItem_Click(object sender, EventArgs e) { MessageBox.Show("打字练习"); } private void 击字字数ToolStripMenuItem_Click(object sender, EventArgs e) { MessageBox.Show(all.ToString()); } private void 正确数ToolStripMenuItem_Click(object sender, EventArgs e) { MessageBox.Show(right.ToString()); } private void 错误数ToolStripMenuItem_Click(object sender, EventArgs e)
using System; using System.Collections.Generic; using ponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; namespace WindowsApplication2 { public partial class Form1 : Form { int right = 0,all = 0, a = 0;

练习文章打字的编程

练习文章打字的编程

#include<dos.h>#include<stdio.h>#include<conio.h>xfk(){char *zq=" ture",*cu="flase",*fs="score"; int i,j,hh=7;textcolor(YELLOW);gotoxy(3,6);cputs(zq);gotoxy(3,11);cputs(cu);gotoxy(3,16);cputs(fs);textcolor(GREEN);for(i=1;i<=3;i++){gotoxy(3,hh);putch('\311');for(j=4;j<=7;j++){gotoxy(j,hh);putch('\315');}gotoxy(8,hh); putch('\273');hh=hh+5;}hh=8;for(i=1;i<=3;i++) {gotoxy(3,hh); putch('\272'); gotoxy(8,hh); putch('\272');hh=hh+5;}hh=9;for(i=1;i<=3;i++) {gotoxy(3,hh); putch('\310');for(j=4;j<=8;j++) {gotoxy(j,hh);putch('\315');}gotoxy(8,hh);putch('\274');hh=hh+5;}textcolor(GREEN);}wcbk(){int thh,tlh;textcolor(WHITE);thh=1;tlh=1;gotoxy(tlh,thh);putch('\332');for(tlh=2;tlh<=78;tlh++){gotoxy(tlh,thh);putch('\304');}gotoxy(tlh,thh);putch('\277');tlh=1;for(thh=2;thh<=25;thh++) {gotoxy(tlh,thh);putch('\263');gotoxy(tlh+78,thh); putch('\263');}thh=25;gotoxy(tlh,thh);putch('\300');for(tlh=2;tlh<=78;tlh++) {gotoxy(tlh,thh);putch('\304');}gotoxy(tlh,thh);putch('\276');textcolor(GREEN);}lcbk(){int thh,tlh;textcolor(YELLOW);thh=3;tlh=10;gotoxy(tlh,thh);putch('\311');for(tlh=11;tlh<=70;tlh++){gotoxy(tlh,thh);putch('\315');}gotoxy(tlh,thh);putch('\273');tlh=10;for(thh=4;thh<=22;thh++){gotoxy(tlh,thh);putch('\272');gotoxy(tlh+61,thh);putch('\272');}thh=23;gotoxy(tlh,thh);putch('\310');for(tlh=11;tlh<=70;tlh++){gotoxy(tlh,thh);putch('\315');}gotoxy(tlh,thh);putch('\274');textcolor(GREEN);}zhhs(char lfilename[20]){int hh=5,lh=13,i,wz=0,cj=4,bj=1,thh,tlh,zq=0,cu=0,fs=0; char *zh,lsslzh,filezh;FILE *fp;if(!(fp=fopen(lfilename,"r"))){printf("cannot open file\n");exit(1);}while(1){wcbk();lcbk();xfk();for(i=1;i<=6;i++){fread(zh,50,1,fp);gotoxy(lh,hh);cputs(zh);hh=hh+3;if(feof(fp)) break;}fseek(fp,wz,0);for(hh=6;hh<=21;hh=hh+3) {for(lh=13;lh<=62;lh++){bj=1;gotoxy(lh,hh);putch(24);gotoxy(lh,hh);filezh=fgetc(fp);wz=wz+1;if((lsslzh=getch())==27) exit(1);if((lsslzh==8)&&!(hh==6&&lh==13)){bj=0;if((lh==13)&&(hh!=6)){putch(' ');lh=62;hh=hh-3;cj=cj-3;}else lh=lh-1;wz=wz-2;gotoxy(lh,hh);putch(' ');gotoxy(lh,cj);putch(' ');gotoxy(lh+1,hh);putch(' ');lh=lh-1;fseek(fp,wz,0);}gotoxy(lh,hh);if(filezh==EOF) return(lsslzh);if(filezh==lsslzh){putch(lsslzh);fs=fs+5;zq=zq+1;gotoxy(4,8);printf("%2d",zq);gotoxy(4,18);printf("%2d",fs);}else{if(bj){cu=cu+1;gotoxy(4,13);printf("%2d",cu); gotoxy(lh,hh);textcolor(RED);putch(lsslzh);gotoxy(lh,cj);putch(25);gotoxy(lh,hh);sound(980);delay(100000);nosound();textcolor(GREEN);}}}cj=cj+3;}delay(2000);textcolor(YELLOW);clrscr();wz=ftell(fp);hh=5;lh=13;cj=4;}}main(){int thh=3,tlh=10;char zh;char *filename, *lesson="1.College Life\n2.study Online\n3.Lesiure Activity\n4.Living on your own";window(1,1,20,40);textbackground(BLUE);textcolor(YELLOW);while(1){clrscr();printf("%s\n",lesson);printf("choice lesson number:");zh=getch();switch(zh){case 49: filename="e:\\fcp\\college.txt";break;case 50: filename="e:\\fcp\\study.txt";break;case 51: filename="e:\\fcp\\lesiure.txt";break;case 52: filename="e:\\fcp\\living.txt";break;case 27: exit(1);default: printf("enter file name:");scanf("%s",filename); }clrscr();zhhs(filename);clrscr();printf("continue practic(y\n):");if(getch()=='n') break;}}。

打字程序代码

打字程序代码

打字程序代码/*练习训练游戏*/#include#include#include#include#include#include#define MAXCHAR 100#define ESC 0x011b /* 退出程序键,调用quitgame()函数*/ #define F10x3b00/* 查看帮助信息,调用Help()函数 */#define F20x3c00/* 查看关于...信息,调用About()函数 */#defineF30x3d00/* 以下功能键暂时保留,如果增加功能可使用*/#defineF40x3e00#defineF50x3f00#defineF60x4000#defineF70x4100#defineF80x4200#defineF90x4300#defineF100x4400#define KEY1 0x0231#define KEY2 0x0332#define KEY3 0x0433#define KEY4 0x0534#define KEY01 0x4f31#define KEY02 0x5032#define KEY03 0x5133#define KEY04 0x4b34char string[MAXCHAR+1];int LittleWin(int WinType/*=1, quitgame; =2, Help;=3, About; =4, others;*/);/*when WinType=1, return 0, quit, return 1, not quit*/void quitgame();void Welcome();void drawframe();void Frame();void GetCharacter();void Typing();int LittleWin(int WinType/*=1, quitgame; =2, Help;=3, About; =4, others;*/)/*when WinType=1, return 0, quit, return 1, not quit*/{int i;char ch;window(18,6,62,20);textbackground(LIGHTGRAY);textcolor(BLACK);clrscr();gotoxy(1,1);cprintf("%c",201);for(i=0;i<43;i++)cprintf("%c",205);cprintf("%c",187);for(i=0;i<13;i++){gotoxy(1,i+2);cprintf("%c",186);gotoxy(45,i+2);cprintf("%c",186);}gotoxy(1,14);cprintf("%c",200);for(i=0;i<43;i++)cprintf("%c",205);cprintf("%c",188);gotoxy(20,1);switch(WinType){case 1:cprintf(" Exit ");textcolor(LIGHTRED);gotoxy(18,3);cprintf("Warning!");textcolor(LIGHTBLUE);gotoxy(5,5);cprintf("This operation will exit the program!"); gotoxy(10,7);cprintf("Do you really want to quit?"); textcolor(LIGHTGREEN);gotoxy(18,9);cprintf("OK? [Y/N]");/*window(18,20,62,20);textbackground(LIGHTBLUE);textcolor(YELLOW);clrscr();*/window(19,18,61,18);textbackground(LIGHTBLUE);textcolor(WHITE);clrscr();gotoxy(5,1);cprintf("Press Y to quit, press N to return."); while(1){ch=getch();if(ch=='Y'||ch=='y')return 0;else if(ch=='N'||ch=='n')return 1;}break;case 2:cprintf(" Help ");break;case 3:cprintf(" About ");break;case 4:cprintf(" Info ");break;default:break;}}void quitgame(){if(LittleWin(1)){Frame();return;}window(1,1,80,25);textbackground(BLACK);textcolor(LIGHTGRAY);clrscr();exit(0);}void Welcome(){int driver=VGA,mode=VGAHI; /*定义变量*/int x1=20,y1=20,r=10,num,i;int x2=20,y2=450;int color1=10,color2=10; /*在此设置颜色,一改全改*/static char ch1[28][2]={"W","e","l","c","o","m","e"," ","t","o"," ","t","h","e"," ","T","y","p","i","n","g"," ","W","o","r","l","d","!"};initgraph(&driver,&mode,"C:\\\c "); /*初始化图形模式*/setbkcolor(LIGHTBLUE);setcolor(color1); /*步骤一、设置当前颜色用于绘图*/for(num=0;num<30;num++){circle(x1,y1,r); /*步骤二、使用当前颜色绘制一个闭合图形*/ setfillstyle(num%12,color1); /*步骤三、设置填充方式*/ floodfill(x1,y1,color1); /*步骤四、对闭合图形进行填充*/ x1+=20;sound(300); /*输出声音*/delay(3000);nosound();}setcolor(color2);for(num=0;num<30;num++){circle(x2,y2,r);setfillstyle(num%12,color2);floodfill(x2,y2,color2);x2+=20;sound(300); /*输出声音*/delay(3000);nosound();}settextstyle(0,0,2);setcolor(LIGHTRED);sound(300); /*输出声音*/delay(3000);nosound();outtextxy(180,90,"^o^ Hello! ^o^");sound(300); /*输出声音*/delay(3000);nosound();setcolor(YELLOW);gotoxy(50,150);for(i=0;i<28;i++){outtextxy(50+i*16,150,ch1[i]);sound(300); /*输出声音*/delay(3000);nosound();}/*outtextxy(50,150,"Welcome to the Typing World!");*/ setcolor(WHITE);outtextxy(50,200,"This is a little");sound(300); /*输出声音*/delay(6000);nosound();outtextxy(100,250,"Typing Training");sound(300); /*输出声音*/delay(6000);nosound();outtextxy(150,300,"Software ... ^_^");sound(300); /*输出声音*/delay(6000);nosound();setcolor(LIGHTMAGENTA);outtextxy(100,350,"Ver. 2004-04-30");sound(300); /*输出声音*/delay(6000);nosound();setcolor(LIGHTGREEN);outtextxy(100,400,"Press any key to start...");sound(300); /*输出声音*/delay(6000);nosound();getch();closegraph(); /*关闭图形*/}void drawframe(){int i;window(1,1,80,1);textbackground(LIGHTGRAY);textcolor(BLACK);clrscr();gotoxy(7,1);cprintf("File Edit Run Compile Project Options Debug Help"); textcolor(RED);gotoxy(7,1);cprintf("F");gotoxy(14,1);cprintf("E");gotoxy(21,1);cprintf("R");gotoxy(27,1);cprintf("C");gotoxy(37,1);cprintf("P");gotoxy(47,1);cprintf("O");gotoxy(57,1);cprintf("D");gotoxy(65,1);cprintf("H");window(1,25,80,25);textbackground(LIGHTGRAY);textcolor(BLACK);clrscr();gotoxy(7,1);printf("F1-Help F2-About F3-Open F4-Restart Ctrl+F9-Run ESC-Quit");textcolor(RED);gotoxy(7,1);cprintf("F1");gotoxy(17,1);cprintf("F2");gotoxy(28,1);cprintf("F3");gotoxy(37,1);cprintf("F4");gotoxy(50,1);cprintf("Ctrl+F9");gotoxy(64,1);cprintf("ESC");window(1,2,80,24);textbackground(LIGHTBLUE);textcolor(LIGHTGRAY);clrscr();gotoxy(1,2);cprintf("%c",213);for(i=0;i<78;i++)cprintf("%c",205);cprintf("%c",184);for(i=0;i<21;i++){gotoxy(1,i+3);cprintf("%c",179);gotoxy(80,i+3);cprintf("%c",179);}gotoxy(1,22);cprintf("%c",192);for(i=0;i<78;i++)cprintf("%c",196);cprintf("%c",217);textcolor(WHITE);gotoxy(37,1);cprintf(" Type ");}void Frame() /*设置菜单函数*/{drawframe();window(2,3,79,22); textbackground(LIGHTBLUE); textcolor(YELLOW);clrscr();gotoxy(25,2);cprintf("The Typing World Menu\"); gotoxy(12,4);cprintf("1:Practice Only ENGLISH Characters."); gotoxy(12,6);cprintf("2:Practice Other Charcters.");gotoxy(12,8);cprintf("3:Practice All Charcters.");gotoxy(12,10);cprintf("4:Quit at once!");GetCharacter();}void GetCharacter(void) /*设置得到字符函数*/{void Typing(); /*声明typing()函数*/FILE *in;int i,t,choice;char ch;t=abs(time(0))%700; /*获取随机数来指定下面指针的位*/ gotoxy(12,12);cprintf("Please input your choice: ");while(1){gotoxy(38,12);choice=bioskey(0);if(choice==ESC||choice==KEY4||choice==KEY04) {quitgame();break;}else if(choice==KEY1||choice==KEY01){in=fopen("english.dat","r");break;}else if(choice==KEY2||choice==KEY02){in=fopen("others.dat","r");break;}else if(choice==KEY3||choice==KEY03){in=fopen("typeall.dat","r");break;}}clrscr(); /*清屏*/fseek(in,t*1l,0);fgets(string,MAXCHAR+1,in);textcolor(WHITE);gotoxy(1,2);cprintf("****************************************************** ************************");textcolor(YELLOW);for(i=0;i<maxchar;i++)cprintf("%c",string[i]);gotoxy(1,5);textcolor(WHITE);cprintf("****************************************************** ************************");fclose(in);gotoxy(1,6);cprintf("Let's begin typing,OK?[Y/N]");while(1){gotoxy(28,6);ch=getch();if(ch=='n'||ch=='N') /*判断是否练习打字*/{quitgame();break;}else if(ch=='y'||ch=='Y'){Typing();break;}}}void Typing(void) /*设置打字(包括计算其他结果)函数*/{int i,j,Right_char=0,Wrong_char=0,Sum_char=0;float Speed,Timeused,Right_rate;char absorb_char,ch_1,ch_2,ch_3;time_t star,stop; /*定义time变量,获取系统时间并显示在屏幕上*/time(&star);textcolor(WHITE);gotoxy(1,6);cprintf("time begin:%s",ctime(&star));gotoxy(1,7);i=0;absorb_char=getch(); /*接受键盘输入的字符并在下面的while 语句判断正错和计算结果*/while(i<maxchar){if(absorb_char=='\')continue;elsecprintf("%c",absorb_char);if(absorb_char==string[i]){Right_char++;Sum_c</maxchar)</maxchar;i++)har++;}else{Wrong_char++;Sum_char++;}i++;absorb_char=getch();}time(&stop);Timeused=difftime(stop,star); /*利用difftime()函数输出所用时间*/Right_rate=(float)Right_char/(float)Sum_char*100;Speed=(Sum_char/Timeused)*60;gotoxy(1,11);cprintf("time end:%s",ctime(&stop)); /*下面显示分数*/textcolor(LIGHTGREEN);gotoxy(1,12);cprintf("********************YourScore!*************************");gotoxy(7,13);textcolor(WHITE);cprintf(" 1: TOTAL TIME USED:%.3f",Timeused);gotoxy(7,14);cprintf(" 2: YOU HAVE TYPED:%d",Sum_char);gotoxy(7,15);cprintf(" 3: Typing Right_Characters are:%d",Right_char);gotoxy(7,16);cprintf(" 4: Typing Wrong_Characters are:%d\",Wrong_char);gotoxy(7,17);cprintf(" 5: YOUR TYPING SPEED IS :%.2f\\\\min\",Speed);gotoxy(7,18);cprintf(" 6: YOUR TYPING RIGHT_RATE IS :%.2f%%\",Right_rate);textcolor(LIGHTGREEN);gotoxy(1,19);cprintf("********************YourScore!*************************");gotoxy(1,20);textcolor(WHITE);if(Speed<=50||Right_rate<=80) /*询问用户是否重来一遍*/{cprintf("Not Very Good! Try it Again,OK?[Y/N]");while(1){gotoxy(39,20);ch_2=getch();if(ch_2=='n'||ch_2=='N'){quitgame();break;}else if(ch_2=='y'||ch_2=='Y'){Frame();break;}}}else{cprintf("Well Done!! One More Time?[Y/N]"); /*询问用户是否重来一遍*/while(1){gotoxy(35,20);ch_3=getch();if(ch_3=='n'||ch_3=='N'){quitgame();break;}else if(ch_3=='y'||ch_3=='Y'){Frame();break;}}}}main(void) /*主函数包含两个要调用的函数*/ {/*Welcome();*/Frame();}。

英文打字练习程序源代码

英文打字练习程序源代码

■ 初学者英文打字练习程序
————————————————以下为程序代码—————————————
Option Explicit
Dim speed, right, wrong, keynum As Integer &#39;定义速度,正确次数,错误次数,击键次数
lbl_time.Caption = 120 &amp; &quot; 秒&quot;
End Sub
Private Sub Command2_Click()
Unload Me
End Sub
Private Sub Form_KeyPress(KeyAscii As Integer)
keynum = keynum + 1
Else
lbl_score.BackColor = vbGreen
Timer1.Enabled = True
Timer2.Enabled = True
End If
End Sub
Private Sub Form_Load()
Form1.Left = (Screen.Width - Form1.Width) / 2
If KeyAscii = 27 Then
Timer1.Enabled = False
Timer2.Enabled = False
lbl_score.BackColor = vbYellow
lbl_score.Caption = &quot;成绩: &quot; &amp; right &amp; &quot;分&quot; &amp; &quot; 错误: &quot; &amp; wrong &amp; &quot; 个&quot; &amp; &quot; 正确率: &quot; &amp; Int(right / keynum * 100) &amp; &quot;%&quot; &amp; &quot; 按任意键继续&quot;

c语言写打字训练程序

c语言写打字训练程序

c语言写打字训练程序
打字训练是提高打字速度和准确度的有效方法,而c语言作为一种高级编程语言,可以利用其强大的功能和语法来编写一个打字训练程序。

一、设定需求
首先要设定需求,即需要让程序能够对用户进行打字速度和准确度的测试,同时需要提供不同难度和不同形式的打字练习。

二、设计程序算法
接下来需要设计程序的算法,即如何实现需求。

可以将程序分为三个模块,分别为输入模块、计算模块和输出模块。

1.输入模块:用户输入打字练习的文本,可以从文件中读取打字练习文本。

需要记录用户的开始时间和结束时间,以便计算用户的打字速度。

2.计算模块:计算模块会根据用户输入的文本和正确答案进行比较,计算用户的打字准确度和速度,并将结果传递给输出模块进行显示。

3.输出模块:输出模块会显示用户的打字速度和准确度,并给出评估。

三、编写程序代码
接下来就可以根据对算法的设计来编写程序代码了。

可以按照模块分别编写代码,其中输入模块可以使用c语言标准库中的文件读写函数进行实现。

计算模块需要编写字符串比较函数和计算打字速度和准确度的函数。

输出模块可以使用printf函数进行简单的命令行输出。

四、测试和优化程序
最后需要对程序进行测试和优化。

可以在代码中加入错误处理机制,防止出现崩溃现象,同时可以对用户接口进行优化,使其更加易用。

总之,使用C语言编写打字训练程序,需要从设定需求开始,设计程序算法,编写代码,测试和优化程序,才能达到预期的效果。


就需要程序员有一定的编程经验和思维能力。

通过不断学习和实践,我们可以不断提高自己的编程水平和技能,创造更加有用和实用的程序。

Python基础练习代码(20条)

Python基础练习代码(20条)

Python基础练习代码(20条)1. 输入两个整数,输出它们的和。

a = int(input("请输入一个整数: "))b = int(input("请输入另一个整数: "))sum = a + bprint("{0} + {1} = {2}".format(a, b, sum))2. 计算一个整数的阶乘。

n = int(input("请输入一个正整数: "))fact = 1for i in range(1, n+1):fact *= iprint("{0}! = {1}".format(n, fact))3. 输入三角形三边的长度,判断是否为直角三角形。

a = float(input("请输入三角形第一条边的长度: "))b = float(input("请输入三角形第二条边的长度: "))c = float(input("请输入三角形第三条边的长度: "))if (a*a + b*b == c*c) or (a*a + c*c == b*b) or (b*b + c*c ==a*a):print("是直角三角形")else:print("不是直角三角形")4. 输入一个字符,判断它是否为大写字母。

ch = input("请输入一个字符: ")if ch >= 'A' and ch <= 'Z':print("{0}是大写字母".format(ch)) else:print("{0}不是大写字母".format(ch)) 5. 输入一个整数,判断它是否为素数。

n = int(input("请输入一个正整数: "))flag = 0if n == 1:print("1不是素数也不是合数")else:for i in range(2, n//2+1):if n % i == 0:flag = 1breakif flag == 0:print("{0}是素数".format(n))else:print("{0}不是素数".format(n))6. 输入一个字符,判断它是否为数字。

C语言入门训练代码(10条)

C语言入门训练代码(10条)

C语言入门训练代码(10条)1. 输入n,计算出n的阶乘。

#include <stdio.h>int main(){int n, i;long long ret = 1;printf("请输入一个正整数:");scanf("%d", &n);for (i=1; i<=n; ++i){ret *= i;}printf("%d的阶乘是%lld\n", n, ret);return 0;}2. 编写一个程序,将一个字符串中的字母全部转换为大写字母。

#include <stdio.h>#include <ctype.h>#define MAX_LEN 100int main(){char str[MAX_LEN + 1];int i;printf("请输入一个字符串:");fgets(str, MAX_LEN, stdin);for (i=0; str[i]!='\0'; ++i){str[i] = toupper(str[i]);}printf("转换后的字符串是:%s", str);return 0;}3. 输入两个正整数m和n,求它们的最大公约数和最小公倍数。

#include <stdio.h>int main(){int m, n, i, gcd, lcm;printf("请输入两个正整数m和n:");scanf("%d %d", &m, &n);for (i=1; i<=m && i<=n; ++i){if (m%i==0 && n%i==0){gcd = i;}}lcm = m*n / gcd;printf("%d和%d的最大公约数是%d,最小公倍数是%d\n", m, n, gcd, lcm);return 0;}4. 输入一组数据,计算它们的平均值以及大于平均值的个数。

用汇编编写的指法打字练习软件TT

用汇编编写的指法打字练习软件TT

Init_boarder macro row,col,char,dhdl,countLocal l1mov cx,countmov dh,rowmov dl,coll1:mov ah,02hmov bh,00hint 10hpush cxmov ah,0ahmov al,charmov bh,00hmov cx,01hint 10hpop cxinc dhdlloop l1endmclear_screen macro top,left,bottom,right,col;清屏宏定义 mov ah,06hmov al,00hmov bh,colmov ch,topmov cl,leftmov dh,bottommov dl,rightint 10hendmsetcusor macro page,row,column;设置光标位置mov ah,02hmov bh,pagemov dl,columnmov dh,rowint 10hendmmenu macro row,col,text;菜单显示宏定义mov ah,02hmov bh,00hmov dh,rowmov dl,colint 10hmov cx,0mov ah,09hlea dx,textint 21hendmdata segment; add your data here!;pkey db "press any key...$"kaishi db " welcome to play the game! $"mes0 db " =========================================$"mes1 db " 1.start game $"mes2 db " 2.select $"mes3 db " 3.exit $"mes4 db " =========================================$"mes5 db " select num of menu:$"mes12 db " =========================================$"mes13 db " 1.100 letters $"mes14 db " 2.200 letters $"mes15 db " 3.300 letters $"mes17 db " =========================================$"mes18 db "Correct Rate:$"mes7 db " press any key to start the game... $"mes8 db " press esc key return main menu $"mes10 db " Select The Letter's Num $"mes19 db " wait... $"mes11 db " when the game was over,press enter to restart$"mes9 db "Used Time:$"mes6 db "The correct number:$"col db 00h,24h,0fdh,0dh;颜色num dw ? ;以输入字母的个数numb dw ? ;输入正确字母的个数score dw ? ;每轮游戏的分数grade dw ?sum dw ?n db 26letters db 500 dup(0)hour db 0minu db 0seco db 0endsstack segmentdw 128 dup(0)endscode segmentstart:; set segment registers:mov ax, datamov ds, axmov es, ax; add your code here;clear_screen 0d,0d,24d,79d,07hFrame1:clear_screen 0d,0d,24d,79d,1eh ;清屏Init_boarder 0d,0d,'*',dl,80d ;显示边框上一排星号Init_boarder 24d,0d,'*',dl,80d ;显示边框下一排星号 Init_boarder 0d,0d,'*',dh,25d ;显示边框左一排星号 Init_boarder 0d,79d,'*',dh,25d ;显示边框右一排星号 menu 5d,20d,mes0menu 6d,26d,kaishi ;显示菜单menu 8d,30d,mes1menu 10d,30d,mes2menu 12d,30d,mes3menu 13d,20d,mes4menu 14d,20d,mes5inputMenuNum:mov ah,7 ;输入功能号,无回显int 21hcmp al,'1'je call num1cmp al,'2'je call num2cmp al,'3'je end1jmp inputMenuNum ;输入不符要求重输Frame2 procmov dl,al ;将选择的功能号显示出来mov ah,2int 21hclear_screen 1d,1d,23d,78d,1eh ;清屏,边框还存在menu 9d,20d,mes7menu 11d,20d,mes8; menu 12d,30d,mes10menu 13d,20d,mes11mov cx,2000h ;隐藏光标mov ah,01h ;设置光标大小int 10hmov ah,7 ;无回显输入字符int 21hmov cx,1010h ;显示光标mov ah,01hint 10hretFrame2 endpnum1 procmov dl,al ;将选择的功能号显示出来mov ah,2int 21hclear_screen 1d,1d,23d,78d,1eh;清屏,但边框存在menu 9d,20d,mes7menu 11d,20d,mes8;menu 12d,30d,mes10menu 13d,20d,mes11mov cx,2000h ;隐藏光标mov ah,01hint 10hmov ah,7 ;无回显输入字符int 21hmov cx,1010h ;显示光标mov ah,01hint 10hmov num,100call playretnum1 endpnum2 procmov dl,al ;将选择的功能号显示出来 mov ah,2int 21hclear_screen 1d,1d,23d,78d,1eh;清屏 menu 7d,20d,mes10menu 8d,20d,mes12menu 10d,20d,mes13menu 11d,20d,mes14menu 12d,20d,mes15menu 14d,20d,mes17menu 15d,20d,mes5inputMenuNum1:mov ah,07hint 21hcmp al,'1'jz m1cmp al,'2'jz m2cmp al,'3'jz m3cmp al,27 ;当输入esc键时退到主菜单 jz Frame1jmp inputMenuNum1m1:call Frame2mov num,100 ;设置字符串个数为100call playjmp m4m2:call Frame2mov num,200call playjmp m4m3:call Frame2mov num,300call playjmp m4m4: retnum2 endpplay procmov numb,0 ;正确字符个数clear_screen 02d,02d,23,78,1eh ;清屏(边框还存在) lea si,lettersmov bx,0call getletter ;调用生成字符串子程序menu 20d,15d,mes19setcusor 0d,3d,10d ;设置光标位置clear_screen 02d,02d,23,78,1eh ;清屏(边框还存在) call outlettersetcusor 0d,4d,10d ;设置光标位置mov ah,2ch ;获取当前时间int 21hmov hour,ch ;获取的小时放入hour中mov minu,cl ;获取的分钟放入minu中mov seco,dh ;获取的秒钟放入seco中call inputlettermenu 20d,5d,mes9call counttimecall outtimemenu 20d,25d,mes6mov ax,numbcall PRINTAXmenu 20d,50d,mes18call CorrectRateinput_quit:mov ah,07hint 21hcmp al,27jz Frame1cmp al,0dhjz call playjmp input_quitretplay endp;*************************************;实现随机产生字符串getletter procoutput_letter:mov ah,2ch ;获取时间 ch为小时,cl为分,dh为秒,dl为1%秒int 21hmov al,dl ;将1%秒放入al中mov ah,0 ;将ah置0,ax当被除数div n ;n为26,将商放到al中,将余数放入ah中mov dl,ah ;将余数放入dl中add dl,61h ;a的ascii码为61,将余数加上61得到随机产生字母的ascii码mov [si],dl ;将随机产生的字符放入到letters中inc si ;letters的偏移量加1inc bxcall DELAY ;计数量加1cmp bx,num ;将已产生的字符量与所需产生的字符数比较jnz output_letter ;当小于所需产生的字符数时,跳转至output_lettermov [si],'$' ;字符串结束retgetletter endp;*************************************;实现字符串的换行输出outletter proclea si,letters ;获取letters的首地址again:mov dl,[si] ;将字符串相应偏移地址里的字符放入dl 中mov ah,02h ;显示字符int 21hinc si ;letters偏移地址加1cmp [si],'$' ;判断是否已经到字符串的末尾jz q2 ;当已到达字符串末尾时跳转至q2,反之顺序执行mov ah,03h ;获取光标当前位置 dh=行号,dl=列号 mov bh,0int 10hcmp dl,75d ;判断光标列号是否为75,即已到达改行末尾jz q1 ;当光标列号是为75跳转至q1jmp againq1: add dh,2d ;将当前光标行号加2,实现隔行输出setcusor 0d,dh,10d ;重新设定光标位置jmp againq2: retoutletter endpinputletter proclea si,letters ;获取字符串的首地址mov cx,num ;将字符串的长度放入cx中input:push cx ;将cx压栈mov ah,03h ;获取光标当前位置 dh=行号,dl=列号 mov bh,0 ;页号为0int 10hcmp dl,75d ;将光标当前列号与75作比较jz l5 ;当光标当前列已是75则跳转到l5l6: mov ah,7 ;输入字符无回显,al接收输入字符的ascii 码int 21hcmp al,08h ;判断输入键是否为退格键(退格键ascii 码为08h)je l3 ;当输入退格键跳转至l3,若不是则往下执行cmp al,27 ;判断输入键是否为esc键(esc键ascii 码为27h)je quit ;当输入的是esc键,跳转至qiut,若不是则往下执行cmp al,[si] ;将输入字符与letters里相应字符比较je l1 ;当相等时跳转至l1,反之往下执行jne l2 ;当输入的字符与letters里相应字符不相等,跳转至l2done: mov dl,al ;将输入的字符放入dl中mov ah,2 ;输出字符int 21hinc si ;letters的偏移量加1pop cxdec cxjnz inputjmp l4l1: add numb,1 ;输入的字符正确,记录输入输入正确个数的numb加1mov ah,09H ;在当前光标位置显示字符,不改变光标位置mov bh,0Hmov bl,2fh ;背景颜色为绿色mov cx,1int 10Hjmp donel2:call SOUND ;输入错误mov ah,09H ;在当前光标位置显示字符,不改变光标位置mov bh,0Hmov bl,4fh ;Z表示颜色。

  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

最近发现很对人需要打字程序的代码,新作了一个,还有些小功能可以自己补充。

ZIP发不上来,只能让大家自己复制下去了。

Option ExplicitSub cswz() '产生位置Randomizewz = Rnd() * (Picture1.Width - 200)End SubSub cszm()RandomizeIf nd = 1 Thenzm = Chr(Int(26 * Rnd + 65))'Label1(0).Caption = Chr(Int((90 - 65 + 1) * Rnd + 65)) '产生一个介于65到90之间的随机数ElseIf nd = 2 Thenzm = Chr(Int(58 * Rnd + 65))Elsezm = Chr(Int(75 * Rnd + 48))End IfEnd SubPrivate Sub Command1_Click()df = 0Command4.Visible = FalseCommand1.Visible = Falsesdsd '调用产生速度设定值Timer1.Interval = sd1syt = 200Picture1.SetFocuscswz '调用产生位置子程序Label1(0).Left = wzcswz '调用产生位置子程序Label1(1).Left = wzcswz '调用产生位置子程序Label1(2).Left = wzcswz '调用产生位置子程序Label1(3).Left = wzcswz '调用产生位置子程序Label1(4).Left = wzcswz '调用产生位置子程序Label1(5).Left = wzcszm '调用产生字母子程序Label1(0).Caption = zmcszm '调用产生字母子程序Label1(1).Caption = zmcszm '调用产生字母子程序Label1(2).Caption = zmcszm '调用产生字母子程序Label1(3).Caption = zmcszm '调用产生字母子程序Label1(4).Caption = zmcszm '调用产生字母子程序Label1(5).Caption = zmTimer1.Enabled = True ' 激活Time1控件Timer2.Enabled = True ' 激活Time2控件Label3.Caption = "当前得分:" & dfLabel4.Caption = "剩余时间:" & sytLabel2.Caption = "当前难度等级:" & ndLabel5.Caption = "当前速度等级:" & sdEnd SubPrivate Sub Command2_Click()EndEnd SubPrivate Sub Command4_Click()Form2.ShowEnd SubPrivate Sub Form_Load()RandomizeTimer1.Enabled = False ' Time1控件失效Timer2.Enabled = False ' Time2控件失效Command1.Visible = FalseEnd SubPrivate Sub Picture1_KeyPress(KeyAscii As Integer)If Chr(KeyAscii) = Label1(0).Caption Thendf = df + 1BeepLabel3.Caption = "当前得分:" & dfcszmcswzLabel1(0).Left = wzLabel1(0).Caption = zmLabel1(0).Top = 0ElseIf Chr(KeyAscii) = Label1(1).Caption Thendf = df + 1BeepLabel3.Caption = "当前得分:" & dfcszmcswzLabel1(1).Left = wzLabel1(1).Caption = zmLabel1(1).Top = 0ElseIf Chr(KeyAscii) = Label1(2).Caption Then df = df + 1BeepLabel3.Caption = "当前得分:" & dfcszmcswzLabel1(2).Left = wzLabel1(2).Caption = zmLabel1(2).Top = 0ElseIf Chr(KeyAscii) = Label1(3).Caption Then df = df + 1Label3.Caption = "当前得分:" & dfcszmcswzBeepLabel1(3).Left = wzLabel1(3).Caption = zmLabel1(3).Top = 0ElseIf Chr(KeyAscii) = Label1(4).Caption Then df = df + 1BeepLabel3.Caption = "当前得分:" & dfcszmcswzLabel1(4).Left = wzLabel1(4).Caption = zmLabel1(4).Top = 0ElseIf Chr(KeyAscii) = Label1(5).Caption Then df = df + 1BeepLabel3.Caption = "当前得分:" & dfcszmcswzLabel1(5).Left = wzLabel1(5).Caption = zmLabel1(5).Top = 0End IfEnd SubPrivate Sub Timer1_Timer()Label1(0).Top = Label1(0).Top + Rnd * 300 Label1(1).Top = Label1(1).Top + Rnd * 300 Label1(2).Top = Label1(2).Top + Rnd * 300 Label1(3).Top = Label1(3).Top + Rnd * 300 Label1(4).Top = Label1(4).Top + Rnd * 300 Label1(5).Top = Label1(5).Top + Rnd * 300 If Label1(0).Top > Picture1.Height Then cszmcswzLabel1(0).Left = wzLabel1(0).Caption = zmLabel1(0).Top = 0End IfIf Label1(1).Top > Picture1.Height Then cszmcswzLabel1(1).Left = wzLabel1(1).Caption = zmLabel1(1).Top = 0End IfIf Label1(2).Top > Picture1.Height Then cszmcswzLabel1(2).Left = wzLabel1(2).Caption = zmLabel1(2).Top = 0End IfIf Label1(3).Top > Picture1.Height Then cszmcswzLabel1(3).Left = wzLabel1(3).Caption = zmLabel1(3).Top = 0End IfIf Label1(4).Top > Picture1.Height Then cszmcswzLabel1(4).Left = wzLabel1(4).Caption = zmLabel1(4).Top = 0End IfIf Label1(5).Top > Picture1.Height ThencszmcswzLabel1(5).Left = wzLabel1(5).Caption = zmLabel1(5).Top = 0End IfEnd SubPrivate Sub Timer2_Timer() '剩余时间扣除计时syt = syt - 1 '扣除剩余个数中的一个Label4.Caption = "剩余时间:" & sytIf syt <= 0 ThenTimer1.Enabled = False ' 剩余个数小于等于0的时候结束练习'Label1.Caption = "" '不显示字母' Label6.Caption = ""Select Case dfCase Is <= 80MsgBox vbCrLf + "别放弃,再来一次!" ' 显示信息框Case Is < 120MsgBox vbCrLf + "成绩不错,加油!"Case Is < 150MsgBox vbCrLf + "再努力做的更好一些!"Case Is > 180MsgBox vbCrLf + "好厉害!最高分呀!"End SelectCommand4.Visible = TrueTimer1.Enabled = FalseTimer2.Enabled = FalseLabel1(0).Caption = ""Label1(1).Caption = ""Label1(2).Caption = ""Label1(3).Caption = ""Label1(4).Caption = ""Label1(5).Caption = ""Label1(0).Top = 0Label1(1).Top = 0Label1(2).Top = 0Label1(3).Top = 0Label1(4).Top = 0Label1(5).Top = 0End IfEnd Sub设定窗口代码:Option ExplicitPrivate Sub Command1_Click()If Option1.Value = True Thennd = 1ElseIf Option2.Value = True Thennd = 2Elsend = 3End IfIf Option4.Value = True Thensd = 1ElseIf Option5.Value = True Thensd = 2Elsesd = 3End IfForm2.Hidemand1.Visible = TrueEnd SubPrivate Sub Form_Load()Option1.Value = TrueOption4.Value = TrueEnd SubPrivate Sub Form_Unload(Cancel As Integer)Form2.HideEnd Sub模块代码:Option ExplicitPublic nd, sd, sd1 As Integer '定义公共变量难度和速度Public df, syt, wz As Integer '定义公共变量分数剩余时间Public zm As String '定义随机产生的字母Public Sub sdsd() '定义速度值If sd = 1 Thensd1 = 800ElseIf sd = 2 Thensd1 = 500Elsesd1 = 300 End If End Sub。

相关文档
最新文档