一个简易的打字速度测量----C编写
2006-03-06 16:32
519 查看
#include<stdio.h>
#include<bios.h>
#include<conio.h>
#include<stdlib.h>
#define WALL 1 /* 边窗的ASCII码 */
#define TIMELIMIT 2 /* 字符下降的速度*/
#define BCOLOR BLACK /* 背景的颜色*/
#define WCOLOR WHITE /*下降的字符颜色*/
int NUM_TEST; /*接受你所输入的测试字符数*/
int X,Y; /* 字符的位置 */
int timeover() /*测试下降的时间是否到*/
{
static long int tm1,tm2;
tm1 = biostime(0,0l);
if(tm1-tm2 > TIMELIMIT) { tm2=tm1; return 1; }
else return 0;
}
void putword( int c)
{
gotoxy(X,Y);
putch(c);
}
void cutword(int bkground)
{
gotoxy(X,Y);
textcolor(bkground);
putch('');
textcolor(WHITE);
}
union key {
unsigned i;
char ch[2];
}bkey;
main()
{
int i, j;
int success,quit=0;
int WORD,count,right;
do{
clrscr();
do{printf("input your test_number that you want:/n");
scanf("%d",&NUM_TEST);
}while(NUM_TEST<0);
clrscr();
printf("if you want to quit,press esc. ");
textbackground(BCOLOR);
textcolor(WCOLOR);
for(i=0;i<=20;i++)
{ gotoxy(20+i,3);putch(WALL);
gotoxy(20+i,23);putch(WALL);
}
for(j=3;j<=23;j++)
{ gotoxy(20,j);putch(WALL);
gotoxy(40,j);putch(WALL);
}
getch();
count = 0;
right = 0;
while(count<NUM_TEST)
{
if(quit == 1) break;
count++;
WORD = 33;
WORD += random(94);
X = 30;Y = 4;
while(1)
{ success = 0;
putword(WORD);
while(!timeover())
{ if(bioskey(1)!=0)
{
bkey.i = bioskey(0);
if(bkey.ch[0] == WORD) { success = 1; cutword(BCOLOR);break; }
if(bkey.ch[0] == 27) {quit = 1;break; }
}
}
if(success == 1) { right++;break; }
else if(quit ==1)break;
cutword(BCOLOR);
++Y;
if(Y>22)break;
}
}
if(quit == 1) break;
clrscr();
printf("count number: %d /nright number: %d/n",NUM_TEST,right);
printf("error number: %d/n",NUM_TEST-right);
printf("try angin ? y/n/n");
do { bkey.i = bioskey(0); }while(bkey.ch[0]!='y' && bkey.ch[0]!='n');
if(bkey.ch[0] == 'n' )break;
}while(1);
}
#include<bios.h>
#include<conio.h>
#include<stdlib.h>
#define WALL 1 /* 边窗的ASCII码 */
#define TIMELIMIT 2 /* 字符下降的速度*/
#define BCOLOR BLACK /* 背景的颜色*/
#define WCOLOR WHITE /*下降的字符颜色*/
int NUM_TEST; /*接受你所输入的测试字符数*/
int X,Y; /* 字符的位置 */
int timeover() /*测试下降的时间是否到*/
{
static long int tm1,tm2;
tm1 = biostime(0,0l);
if(tm1-tm2 > TIMELIMIT) { tm2=tm1; return 1; }
else return 0;
}
void putword( int c)
{
gotoxy(X,Y);
putch(c);
}
void cutword(int bkground)
{
gotoxy(X,Y);
textcolor(bkground);
putch('');
textcolor(WHITE);
}
union key {
unsigned i;
char ch[2];
}bkey;
main()
{
int i, j;
int success,quit=0;
int WORD,count,right;
do{
clrscr();
do{printf("input your test_number that you want:/n");
scanf("%d",&NUM_TEST);
}while(NUM_TEST<0);
clrscr();
printf("if you want to quit,press esc. ");
textbackground(BCOLOR);
textcolor(WCOLOR);
for(i=0;i<=20;i++)
{ gotoxy(20+i,3);putch(WALL);
gotoxy(20+i,23);putch(WALL);
}
for(j=3;j<=23;j++)
{ gotoxy(20,j);putch(WALL);
gotoxy(40,j);putch(WALL);
}
getch();
count = 0;
right = 0;
while(count<NUM_TEST)
{
if(quit == 1) break;
count++;
WORD = 33;
WORD += random(94);
X = 30;Y = 4;
while(1)
{ success = 0;
putword(WORD);
while(!timeover())
{ if(bioskey(1)!=0)
{
bkey.i = bioskey(0);
if(bkey.ch[0] == WORD) { success = 1; cutword(BCOLOR);break; }
if(bkey.ch[0] == 27) {quit = 1;break; }
}
}
if(success == 1) { right++;break; }
else if(quit ==1)break;
cutword(BCOLOR);
++Y;
if(Y>22)break;
}
}
if(quit == 1) break;
clrscr();
printf("count number: %d /nright number: %d/n",NUM_TEST,right);
printf("error number: %d/n",NUM_TEST-right);
printf("try angin ? y/n/n");
do { bkey.i = bioskey(0); }while(bkey.ch[0]!='y' && bkey.ch[0]!='n');
if(bkey.ch[0] == 'n' )break;
}while(1);
}
相关文章推荐
- JavaScript编写一个简易购物车功能
- JavaScript编写一个简易购物车功能
- 继上一个三级联动的补充--使用jQuery编写各种浏览器兼容简易项目
- 一个没有MYSQL数据库支持的简易留言本的编写
- 编写一个简易购物车,实现向购物车内添加商品,移除指定商品及清空购物车功能。
- 编写一个简易shell命令行
- React编写一个简易的评论区组件
- Python使用tcp编写一个简易的文件下载器(服务端和客户端)
- 【Java】实现一个简易记事本Notepad的编写
- 任务02——安装 Intellj IDEA,编写一个简易四则运算小程序,并将代码提交到 GitHub
- python day05 编写一个给定多项式的简易计算机 re模块及正则匹配应用
- 编写一个简易的 HTTP 服务器程序
- 一个没有MYSQL数据库支持的简易留言本的编写
- 异步Socket编写的一个简易的聊天室
- 编写一个简易的留言薄,实现添加留言和显示留言内容的功能
- 编写一个简易的 HTTP 服务器程序
- Java学习笔记——实现一个简易记事本Notepad的编写
- Angular2-编写一个简易的组件
- 用Linux编写程序,实现一个简易的进度条
- 编写一个简易的Java NIO Reactor库