简易打字测试

本文介绍了一款基于C语言实现的简易打字游戏程序。该程序具备三种难度等级供玩家选择,并能根据玩家表现评估其打字速度及准确性。通过随机选取文章段落和计时功能增强游戏体验。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

功能:(1)三种LEVEL;(2)根据LEVEL选择计时;(3)随机选择文章;(4)显示打字能力,并判断是否通关

待解决问题:提前打完了怎么办?

//打字游戏

#include <stdio.h>
#include <time.h>
#include <stdlib.h>
#include <string.h>

int choose(char passage[][1000]);//随机选文函数
int counttime(int t);//计时函数
int piont(char *passage,char *answer,int t,int *letter,int *speed,int *correct,int *total);//统分函数

int main(void)
{
    char passage[3][1000]={"  Once when I was six years old I saw a magnificent picture in a book, called True Stories from Nature, about the primeval forest. It was a picture of a boa constrictor in the act of swallowing an animal. Here is a copy of the drawing. In the book it said, Boa constrictors swallow their prey whole, without chewing it.",
        "  My drawing was not a picture of a hat. It was a picture of a boa constrictor digesting an elephant. But since the grown-ups were not able to understand it, I made another drawing: I drew the inside of the boa constrictor, so that the grown-ups could see it clearly. They always need to have things explained. My Drawing Number Two looked like this: The grown-ups response, this time was to advise me to lay aside my drawings of boa constrictors, whether from the inside or the outside, and devote myself instead to geography, history, arithmetic and grammar.",
        "  That is why, at the age of six, I gave up what might have been a magnificent career as a painter. I had been disheartened by the failure of my Drawing Number One and my Drawing Number Two. Grown-ups never understand anything by themselves, and it is tiresome for children to be always and forever explaining things to them."
    };
    char answer[500];
    int total,letter,speed,correct,level,which,t[3]={180,120,60};
//    total文章总字数,letter输入的总字数,speed输词速度(只计算准确的量),correct正确字数,level选择级别,which抽中文章,t总计时
    printf("Easy1, Medium2, Hard3?\n");
    scanf("%d",&level);
    
    which = choose(passage);
    
    counttime(t[level-1]);
    gets(answer);
    
    piont(passage[which],answer,t[level-1],&letter,&speed,&correct,&total);
    printf("Level %d\n\
In %d seconds, you had printed %d letters, in which %d one are correct.\nYour speed is %d letter/min.\n",level,t[level-1],letter,correct,speed);
    
    if (correct > total*8/10)
    {
        printf("You passed level %d!\n",level);
    }
    else
        printf("Fail the challenge!\n");
    
    return 0;
}

int choose(char passage[][1000])
{
    int i;
    srand((unsigned)time(NULL));
    i = rand()%3;
    
    printf("%s\n",passage[i]);
    printf("\n");
    
    return i;
}

int counttime(int t)
{
    long a,b;
    
    printf("Start now?\n");
    getchar();
    getchar();
    printf("Start!\n");
    
    a = time(NULL);
    while (1)
    {
        b = time(NULL);
        if ((b-a)>=t)
        {
            printf("\n%d seconds off!\n",t);
            break;
        }
    }

    return 0;
}

int piont(char *passage,char *answer,int t,int *letter,int *speed,int *correct,int *total)
{
    int i;
    *correct = 0;
    
    for (i=0; passage[i] != '\0'; i++)
    {
        ;
    }
    *total = i;
    
    for (i=0; answer[i] != 0; i++)
    {
        if (passage[i] == answer[i])
        {
            (*correct)++;
        }
    }
    *letter = i;
    
    *speed = (*correct)*60/t;
    
    return 0;
}


选文摘自The Little Prince

 

 

 

1.系统界面:就三项选择功能键。 练习/考试/设置 2.练习第一界面的用户选择及练习内容选择。 3.测试第一页面与练习页面基本相同,但没有测试项目的情况下无法进入本页。如只有一个测试项目的情况下系统不会出现选择文本的列表框。 4.练习/测试页面。应该是本系统最核心的部分了。 功能:1.页面内容无法复制及粘贴,包括从外都没无法复制到本输入框中,光标始终在输入文本最后,输入后无法修改中间的文本; 2.开始输入以键盘击键即开始,到时间或输入全部内容后结束。结束后无法再输入; 3.输入对错自动判断,当输入正确,原字符变绿,错误则变红,当前输入字符突出显示; 4.进度实时显示,并上传服务器。管理员可以随时了解每位学生的输入情况; 5.练习/测试的排名前10学生及输入速度显示。 5.管理员登录界面。 6.后台的学生导入。 7.后台的练习文本管理。练习时间的管理;添加/删除练习文本功能,学生使用练习文本的次数会被记录。 8.后台的测试文本管理。 功能:1.每个测试可设置独立的测试时间; 2.设置测试的开放时间和测试的结束时间,有此时间段外将无法登录测试; 3.测试内容的修改及删除功能; 9.练习/测试情况在线/结果的柱状实时显示。 10.练习/测试结果的显示与导出。 本系统基于.net 4.0开发,服务器环境要求:IIS+.net4.0
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值