标题:高手进,C++源代码(测打字速度与正确率)是否正确??
只看楼主
a12030689
Rank: 1
等 级:新手上路
帖 子:14
专家分:0
注 册:2008-3-30
 问题点数:0 回复次数:0 
高手进,C++源代码(测打字速度与正确率)是否正确??
#include   <time.h>
#include   <conio.h>
#include   <stdio.h>
#include   <string.h>
#include   <stdlib.h>
#define   LEN   20
const   char   *str= "1234567890abcdefGHIJKLMNOPQRSTUVWXYZ ";
int   len=strlen(str);
int   ln=0,col=0;   //   当前输入到第几行第几列   
char   line[LEN];   //   显示一行字符用于比照输入   

void   ShowLine()
{
    col=0;
    ++ln;
    for   (int   i=0;   i <LEN;   ++i)
    {
        line[i]=str[rand()%len];
        putch(line[i]);
    }
    putch( '\n ');
}

int   main()
{
    int   cn=0;     //   输错字符统计   
    srand(time(0));
    ShowLine();
    while(true)
    {
        if   (ln==10)   break;
        if   (kbhit())
        {
            int   ch=getche();
            if   (ch==27)   break;   //   按ESC键退出程序   
            if   (ch==13)   ShowLine();
            else   if   (ch!=line[col++])
            {
                ++cn;
                _beep(1000,100);   //   Dev-C++   在TC中用sound()   
            }
        }
    }
    printf( "\nerror=%d\n ",cn);
    getch();
    return   0;
}
搜索更多相关主题的帖子: 源代码 正确率 include 
2008-03-30 14:51



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-206175-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 1.620497 second(s), 7 queries.
Copyright©2004-2025, BCCN.NET, All Rights Reserved