⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 c—dazi.txt

📁 主要是一个c语言编写的打字程序
💻 TXT
字号:
/*一个打字游戏,供给初学者进行打字练习,让他们可以在短时间内熟悉键盘上的各个字符键的位置*/
#include"stdio.h"
#include"time.h"
#include"stdlib.h"
#include"string.h"
void pingbi(float t)             //一个 判断 成绩 级别 的函数
{
     printf("********************Your Score********************\n");
     if(t<=0.5)
         printf("Bad!");
         else if(t<=0.7)
         printf("Not Very Good!");
         else if(t<=0.9)
             printf("Good");
         else printf("Very Good!");
}
float s1()
{ 
    char r[1000],w[1000],ch;
    int k,R_Ch,W_Ch,i;
    float t;
    FILE *fp;
    time_t now;
    long time_s = 0,time_s1=0;
    if((fp=fopen("only english.txt","r"))==NULL)
    {printf("can't open this file.");exit(0);}     //打开已知的纯英文文件
    printf("**********************************************************************\n");
    for(i=0;(ch=fgetc(fp))!=EOF;i++) 
    {r[i]=ch;putchar(r[i]);}                    //从文件中读出 数据 且 输出
    
    printf("\n**********************************************************************\n");
   time(&now);                                // 取得 开始 的日期时间 
    time_s=time( NULL );                  //提取 此时  到 1990年的 秒数
    printf("time begin:%s",ctime(&now));       // 打印 开始 的时间
    gets(w);                                      //玩家 输入 数据 
    time(&now);                                  //  取得结束的日期时间 
    time_s1 = time( NULL );               //提取 此时  到 1990年的 秒数
     printf("time end:%s",ctime(&now));               // 打印结束的时间
    for(i=0,k=0;w[i]!='\0';i++)
        k++;                                      //对输入数据进行统计个数
    
    
    for(i=0,R_Ch=0,W_Ch=0;i<k;i++)             
    {
        if(r[i]==w[i])
            R_Ch++;
        else W_Ch++;                            //对玩家输入的数据的 对错进行统计
    }
    t=(float)time_s1-time_s;
    printf("********************Your Score********************\n");
    printf("1:TOTAL TIME USED:%.3f\n",t);
    printf("2:YOU HAVE TYPED:%d\n",k);
    printf("3:Typing Right_Characters are:%d\n",R_Ch);
    printf("4:Typing Wrong_Characters are:%d\n",W_Ch);
    printf("5:YOUR TYPING SPEED IS:%.2f\\min\n",k*60/t);
    printf("6:YOUR TYPING RIGHT_RATE IS:%.2f%c\n",1.0*(100*R_Ch)/k,'%');

    return((float)R_Ch/k);
}
float s2()
{ 

    char r[1000],w[1000],ch;
    int k,R_Ch,W_Ch,i;
    float t;
    FILE *fp;
    time_t now;
    long time_s = 0,time_s1=0;
    if((fp=fopen("others.txt","r"))==NULL)
    {printf("can't open this file.");exit(0);}     //打开已知的纯字符文件
    printf("**********************************************************************\n");
    for(i=0;(ch=fgetc(fp))!=EOF;i++) 
    {r[i]=ch;putchar(r[i]);}                    //从文件中读出 数据 且 输出
    
    printf("\n**********************************************************************\n"); 

    time(&now);                                // 取得 开始 的日期时间 
    time_s=time( NULL );                  //提取 此时  到 1990年的 秒数
    printf("time begin:%s",ctime(&now));       // 打印 开始 的时间
    gets(w);                                      //玩家 输入 数据 
    time(&now);                                  //  取得结束的日期时间 
    time_s1 = time( NULL );               //提取 此时  到 1990年的 秒数
     printf("time end:%s",ctime(&now));               // 打印结束的时间
    for(i=0,k=0;w[i]!='\0';i++)
        k++;                                      //对输入数据进行统计个数
    
    
    for(i=0,R_Ch=0,W_Ch=0;i<k;i++)             
    {
        if(r[i]==w[i])
            R_Ch++;
        else W_Ch++;                            //对玩家输入的数据的 对错进行统计
    }
    t=(float)time_s1-time_s;
    printf("********************Your Score********************\n");
    printf("1:TOTAL TIME USED:%.3f\n",t);
    printf("2:YOU HAVE TYPED:%d\n",k);
    printf("3:Typing Right_Characters are:%d\n",R_Ch);
    printf("4:Typing Wrong_Characters are:%d\n",W_Ch);
    printf("5:YOUR TYPING SPEED IS:%.2f\\min\n",k*60/t);
    printf("6:YOUR TYPING RIGHT_RATE IS:%.2f%c\n",1.0*(100*R_Ch)/k,'%');

    return((float)R_Ch/k);
}
float s3()
{ 

    char r[1000],w[1000],ch;
    int k,R_Ch,W_Ch,i;
    float t;
    FILE *fp;
    time_t now;
    long time_s = 0,time_s1=0;
    if((fp=fopen("all.txt","r"))==NULL)
    {printf("can't open this file.");exit(0);}     //打开已知的包含所有字符文文件
    printf("**********************************************************************\n");
    for(i=0;(ch=fgetc(fp))!=EOF;i++) 
    {r[i]=ch;putchar(r[i]);}                    //从文件中读出 数据 且 输出
    
    printf("\n**********************************************************************\n");
    time(&now);                                // 取得 开始 的日期时间 
    time_s=time( NULL );                  //提取 此时  到 1990年的 秒数
    printf("time begin:%s",ctime(&now));       // 打印 开始 的时间
    gets(w);                                      //玩家 输入 数据 
    time(&now);                                  //  取得结束的日期时间 
    time_s1 = time( NULL );               //提取 此时  到 1990年的 秒数
     printf("time end:%s",ctime(&now));               // 打印结束的时间
    for(i=0,k=0;w[i]!='\0';i++)                  //
      k++;                                      //对输入数据进行统计个数
    
    
    for(i=0,R_Ch=0,W_Ch=0;i<k;i++)             
    {
        if(r[i]==w[i])
            R_Ch++;
        else W_Ch++;                            //对玩家输入的数据的 对错进行统计
    }
    t=(float)time_s1-time_s;
    printf("********************Your Score********************\n");
    printf("1:TOTAL TIME USED:%.3f\n",t);
    printf("2:YOU HAVE TYPED:%d\n",k);
    printf("3:Typing Right_Characters are:%d\n",R_Ch);
    printf("4:Typing Wrong_Characters are:%d\n",W_Ch);
    printf("5:YOUR TYPING SPEED IS:%.2f\\min\n",k*60/t);
    printf("6:YOUR TYPING RIGHT_RATE IS:%.2f%c\n",1.0*(100*R_Ch)/k,'%');

    return((float)R_Ch/k);
}
float s4()
{exit(0);}
void main()
{   
    int x;float t;char k;
loop_1: printf("             The Typing World Menu\n");
        printf("1:Practice Only ENGLISH Charcters.\n");
        printf("2:Practice Other Charcters.\n");
        printf("3:Practice All Charcters.\n");
        printf("4:Quit at once.\n");
        printf("Please input your choice:");
        scanf("%d",&x);
          getchar();
       if(x==1)
        t=s1();
         else if(x==2)
             t=s2();
         else if(x==3)
             t=s3();
         else if(x==4)
loop_2: s4();
        pingbi(t);
        printf("   Try it Again,OK? [Y/N]");
        scanf("%c",&k);
         if(k=='Y'||k=='y')
             goto loop_1;
         else if(k=='N'||k=='n')
             goto loop_2;
} 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -