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

📄 start.c

📁 学生成绩管理系统: 初始的学生成绩信息文件名为porduct
💻 C
字号:
#include<stdlib.h> 
#include<time.h> 
#include<stdio.h> 
/*读取榜首信息*/
#include "readrec.c"
/*刷新排行榜*/
#include "reset.c"
#include "dos.h"
char ch;
char answer[200];
char answerchar;
char paper[200];
int score;
float right;
int i,plength;/*plength是试卷中原始字符数*/
StartProgram()
{ 
    struct time tim;

    ReadRecord();/*调用读取破纪录者函数*/
    getpaper();/*调用试卷*/
    /*显示试卷*/
    printf("the content of test question is:\n");
    for(i=0;i<plength;i++)
        {
        printf("%c",paper[i]);
        }
    /*显示开始时间*/
    gettime(&tim); 
    printf("\nthe time is:%02d:%02d:%02d\n",tim.ti_hour,tim.ti_min,tim.ti_sec);
    /*sprintf(shijie,"%02d:%02d:%02d",tim.ti_hour,tim.ti_min,tim.ti_sec);*/
    /*输入测验答案*/
    printf("\nplease input your answer,end with enter key:\n");
    for(i=0;i<plength;i++)
        {
        scanf("%c",&answerchar);
        answer[i]=answerchar;
        }
    /*显示结束时间*/
    gettime(&tim); 
    printf("\nexamination end,the end time is:%02d:%02d:%02d\n",tim.ti_hour,tim.ti_min,tim.ti_sec);
    printf("your answer is:\n");  /*显示答案*/
    for(i=0;i<plength;i++)
        {
        printf("%c",answer[i]);
        }
    /*计算分数:*/
    right=0;
    for(i=0;i<plength;i++)
        {
        if(paper[i]==answer[i])
        right++;
        } /*统计正确的字符数*/
    score=(int)(right/plength*100);
    printf("\nyour score is:%d",score);
     /*结束后写入纪录文件*/
    ResetRecord(score);
    getch();
}
getpaper()/*随机产生4个数的函数*/
{ 
    FILE *fp;
    char paperchar;
    char choose;
    char paperfile[20]="";
    /*试卷选择界面*/
    printf("\nplease choose the paper to test:\n");
    printf("+++++++++++++++++++\n");
    printf("+ a | paper1.txt  +\n");
    printf("+ b | paper2.txt  +\n");
    printf("+ c | paper3.txt  +\n");
    printf("+ d | paper4.txt  +\n");
    printf("enter your choose here:");
    scanf("%c",&choose);
    getchar();
    switch(choose)
        {
        case 'a':
            strcpy(paperfile,"paper1.txt");
            break;
        case 'b':
            strcpy(paperfile,"paper2.txt");
            break;
        case 'c':
            strcpy(paperfile,"paper3.txt");
            break;
        case 'd':
            strcpy(paperfile,"paper4.txt");
            break;
        }

    fp = fopen(paperfile,"r");/*以读方式打开文件*/
    if (fp == NULL)
    {
        printf("\n Open file fail!End with any key.\n");
        perror("Open file fail");
        getch();
        exit(1);
    }
    paperchar=fgetc(fp);/*读取第一个字符*/
    plength=0;
    while(paperchar!=EOF)
        {
        paper[plength]=paperchar;
        paperchar=fgetc(fp);
        plength++;
        }/*计算试卷中原始字符数,存放在plength变量中*/
    fclose(fp);
}

⌨️ 快捷键说明

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