| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 852 人关注过本帖
标题:打字测速程序
只看楼主 加入收藏
无水之冰
Rank: 2
等 级:论坛游民
帖 子:54
专家分:41
注 册:2007-6-5
结帖率:100%
收藏
 问题点数:0 回复次数:1 
打字测速程序
打字程序主要是让选择的文本内容隔行显示,关键是要在空行的区域输入文字,这个怎么实现?各位大侠不吝赐教一下
搜索更多相关主题的帖子: 打字 
2010-04-11 14:49
小海豚
Rank: 1
来 自:扬州
等 级:新手上路
帖 子:6
专家分:0
注 册:2010-9-16
收藏
得分:0 
C/C++的代码
#include<stdlib.h>
#include<time.h>
#include<stdio.h>

int main()
{
    FILE* fp;
    long t, fpos, maxpos;
    double start,finish;
    char buf_out[100];
    char ch_ans = 'Y';
    int ch_file,i,count;
    fp = fopen("1.txt", "r");
    fseek(fp, SEEK_SET,SEEK_END);
    maxpos = ftell(fp);
    while(ch_ans != 'n')
    {
        count = i = 0;
        srand((unsigned)time(&t));
        fpos = rand()%maxpos;
        fseek(fp,fpos,SEEK_SET);
        while((ftell(fp)<maxpos)&&(ch_file=fgetc(fp)!= ' '))
            ;
        if(ftell(fp) == maxpos)
            fseek(fp, 0, SEEK_SET);
        fscanf(fp,"%s ", buf_out);
        printf("output:%s\ninput: ", buf_out);
        fflush(stdin);
        start = (double)clock();
        while(((ch_ans=getchar()) != ' ') && ch_ans != '\n')
        {
            if((buf_out[i] != '/0') && buf_out[i++] == ch_ans)
                count ++;
        }
        finish = (double)clock();
        printf("correct: %d time used: %4.2fms\ntest again?(y/n) ",count,finish-start);
        fflush(stdin);
        ch_ans = getchar();
    }
    fclose(fp);
    return 0;
}

2010-11-17 10:35
快速回复:打字测速程序
数据加载中...
 
   



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

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