正文

打字程序=<支持BackSpace键+准确率+每分钟打字数>2005-12-19 16:14:00

【评论】 【打印】 【字体: 】 本文链接:http://blog.pfan.cn/smile/8579.html

分享到:

#include<stdio.h>
#include<conio.h>
#include<time.h>
char Article[] = "I,LOVE YOU. longjiaolan.Over eleven years of extensive computer/electronics"
" experience.Versed in both digital and analog electronics with"
" specific emphasis on computer hardware/software.Special expertise"
" in system and component evaluation.Network supervisor responsible "
" for installing/maintaining Arcnet LAN system.";

void main()
{
    int i, right = 0;
    char ch;
    int Len = sizeof(Article);
    time_t begin, end;
    clrscr();
    printf("%s\n\n", Article); /*输出你定义好的字符*/
    begin = clock();
    for (i=0; i<Len; i++){
        ch = getch();
        if (ch == 8){
            putchar('\b');
            putchar(' ');
            putchar('\b');
            i -= 2;
            continue;
        }
        if (ch == Article[i])  /*如果跟你输出的一致,文本颜色为绿色*/

       {  
            textcolor(GREEN);
            right++;
        }
        else {
            textcolor(RED); /*否则输出为红色*/
        }
        cprintf("%c",ch);
    }
    end = clock();
    printf("\nRight: %.2lf%%\n\n", 100*right/(double)(Len-1));
    printf("%.2lf characters per minute!\n", 60*Len/difftime(end,begin));
    printf("Press 'Y' to exit!\n"); /*按Y退出*/
    while (getch() != 'Y');
}

阅读(268) | 评论(0)


版权声明:编程爱好者网站为此博客服务提供商,如本文牵涉到版权问题,编程爱好者网站不承担相关责任,如有版权问题请直接与本文作者联系解决。谢谢!

评论

暂无评论
您需要登录后才能评论,请 登录 或者 注册