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

📄 system.c

📁 学籍管理 包括1. 学生基本数据输入功能 2. 学生成绩输入功能 3. 学生数据和成绩的更新和删除功能 4. 按姓名/学号查找学生成绩功能 5. 按学号排序输出学生数据、各科成绩和平均成绩
💻 C
📖 第 1 页 / 共 5 页
字号:
                fscanf(fp,"!%ldS%c",&templong,&ch);
                newstudent->studentid=templong*33+(long)ch-32-j;
                fscanf(fp,"%c",&ch);
                tempint1=(int)ch-j/2-32;
                for(i=0;i<tempint1;i++)
                {
                    fscanf(fp,"%d%*c",&tempint2);
                    newstudent->studentname[i]=(char)(tempint2+j);
                }
                newstudent->studentname[i]='\0';
                fscanf(fp,"%d",&tempint1);
                newstudent->sex=(char)tempint1;
                fscanf(fp,"$$%d,",&tempint1);
                newstudent->age=tempint1-j;
                fscanf(fp,"%c",&ch);
                tempint1=(int)ch-j/3-42;
                for(i=0;i<tempint1;i++)
                {
                    fscanf(fp,"%c%*c",&ch);
                    newstudent->birthday[i]=(char)((int)ch+i-j/2);
                }
                newstudent->birthday[i]='\0';
                fscanf(fp,"%c",&ch);
                tempint1=(int)ch-j/4-52;
                for(i=0;i<tempint1;i++)
                {
                    fscanf(fp,"%c",&ch);
                    newstudent->identity[i]=(char)((int)ch-j/2-2);
                }
                newstudent->identity[i]='\0';
                fscanf(fp,"%c",&ch);
                tempint1=(int)ch-j/5-62;
                for(i=0;i<tempint1;i++)
                {
                    fscanf(fp,"%d%*c",&tempint2);
                    newstudent->province[i]=(char)(tempint2+j);
                    j++;
                }
                newstudent->province[i]='\0';
                fscanf(fp,"%c",&ch);
                tempint1=(int)ch-64;
                for(i=0;i<tempint1;i++)
                {
                    fscanf(fp,"%d%*c",&tempint2);
                    newstudent->city[i]=(char)(tempint2-j);
                    j++;
                }
                newstudent->city[i]='\0';
                fscanf(fp,"%c",&ch);
                tempint1=(int)ch-64;
                for(i=0;i<tempint1;i++)
                {
                    fscanf(fp,"%d%*c",&tempint2);
                    newstudent->address[i]=(char)(tempint2+j);
                    j++;
                }
                newstudent->address[i]='\0';
                fscanf(fp,"%c",&ch);
                tempint1=(int)ch-64;
                for(i=0;i<tempint1;i++)
                {
                    fscanf(fp,"%d%*c",&tempint2);
                    newstudent->college[i]=(char)(tempint2-j);
                    j++;
                }
                newstudent->college[i]='\0';
                fscanf(fp,"%c",&ch);
                tempint1=(int)ch-64;
                for(i=0;i<tempint1;i++)
                {
                    fscanf(fp,"%d%*c",&tempint2);
                    newstudent->department[i]=(char)(tempint2+j);
                    j++;
                }
                newstudent->department[i]='\0';
                fscanf(fp,"\"%dC%c",&tempint1,&ch);
                newstudent->numofcourses=tempint1*95+(int)ch-544;
                fscanf(fp,"\'%dPC%c",&tempint1,&ch);
                newstudent->passedcourses=tempint1*95+(int)ch-1056;
                fscanf(fp,"<%dH%c",&tempint1,&ch);
                newstudent->totalcredithour=tempint1*95+(int)ch-2080;
                fscanf(fp,">%dPH%c",&tempint1,&ch);
                newstudent->passedcredithour=tempint1*95+(int)ch-4128;
                fscanf(fp,"#%f",&tempfloat);
                newstudent->averagescore=tempfloat+123.45+j;
                newstudent->courselist=NULL;
                for(i=1;i<=newstudent->numofcourses;i++)
                {
                    newcourse=(struct course *)malloc(sizeof(struct course));
                    fscanf(fp,"{%dC%c",&tempint1,&ch);
                    newcourse->courseid=tempint1*33+(int)ch-32-j;
                    fscanf(fp,"|%c",&ch);
                    newcourse->credithour=(int)ch-j%33-58;
                    fscanf(fp,"}%f~",&tempfloat);
                    newcourse->score=tempfloat+67.8+j;
                    if(newcourse->score>=60.0)
                        newcourse->ispassed=1;
                    else
                        newcourse->ispassed=0;
                    fscanf(fp,"%c",&ch);
                    tempint1=(int)ch-64;
                    for(tempi=0;tempi<tempint1;tempi++)
                    {
                        fscanf(fp,"%d%*c",&tempint2);
                        newcourse->coursename[tempi]=(char)(tempint2-j);
                        j++;
                    }
                    newcourse->coursename[tempi]='\0';
                    newcourse->nextcourse=NULL;
                    if(i==1)
                    {
                        newstudent->courselist=newcourse;
                        listend=newstudent->courselist;
                    }
                    else
                    {
                        listend->nextcourse=newcourse;
                        listend=listend->nextcourse;
                    }
                }
                newstudent->nextstudent=NULL;
                listhead=addstudent(newstudent, listhead, issuccessful);
                if(*issuccessful)
                    (*counter)++;
            }
            fclose(fp);
            printf("\nImport from file %s successfully.\n",filename);
        }
    }
    else
    {
        fscanf(fp,"umber Of Students: %d",&tempcounter);
        if(tempcounter==0)
        {
            fclose(fp);
            printf("\n%s %s.\n","No students data is in the file",filename);
        }
        else
        {
            fgetc(fp);
            fgetc(fp);
            for(k=1;k<=tempcounter;k++)
            {
                newstudent=(struct student *)malloc(sizeof(struct student));
                fscanf(fp,"ID: %ld",&newstudent->studentid);
                fgetc(fp);
                fscanf(fp,"Name: ");
                for(i=0;(ch=fgetc(fp))!='\n';i++)
                    newstudent->studentname[i]=ch;
                newstudent->studentname[i]='\0';
                fscanf(fp,"Sex: %s",tempsex);
                fgetc(fp);
                newstudent->sex=tempsex[0];
                fscanf(fp,"Age: %d",&newstudent->age);
                fgetc(fp);
                fscanf(fp,"Birthday: %s",newstudent->birthday);
                fgetc(fp);
                fscanf(fp,"Identity Card Number: %s",newstudent->identity);
                fgetc(fp);
                fscanf(fp,"Province: ");
                for(i=0;(ch=fgetc(fp))!='\n';i++)
                    newstudent->province[i]=ch;
                newstudent->province[i]='\0';
                fscanf(fp,"City: ");
                for(i=0;(ch=fgetc(fp))!='\n';i++)
                    newstudent->city[i]=ch;
                newstudent->city[i]='\0';
                fscanf(fp,"Address: ");
                for(i=0;(ch=fgetc(fp))!='\n';i++)
                    newstudent->address[i]=ch;
                newstudent->address[i]='\0';
                fscanf(fp,"College: ");
                for(i=0;(ch=fgetc(fp))!='\n';i++)
                    newstudent->college[i]=ch;
                newstudent->college[i]='\0';
                fscanf(fp,"Department: ");
                for(i=0;(ch=fgetc(fp))!='\n';i++)
                    newstudent->department[i]=ch;
                newstudent->department[i]='\0';
                fscanf(fp,"Number Of Courses: %d",&newstudent->numofcourses);
                fgetc(fp);
                fscanf(fp,"Passed Courses: %d",&newstudent->passedcourses);
                fgetc(fp);
                fscanf(fp,"Total Credit Hour: %d",&newstudent->totalcredithour);
                fgetc(fp);
                fscanf(fp,"Passed Credit Hour: %d",&newstudent->passedcredithour);
                fgetc(fp);
                fscanf(fp,"Average Score: %f",&tempfloat);
                newstudent->averagescore=tempfloat;
                fgetc(fp);
                newstudent->courselist=NULL;
                fscanf(fp,"=============Courses Information=============");
                fgetc(fp);
                fscanf(fp,"Course ID   Credit Hour   Score   Course Name");
                fgetc(fp);
                for(i=1;i<=newstudent->numofcourses;i++)
                {
                    newcourse=(struct course *)malloc(sizeof(struct course));
                    fscanf(fp,"%d",&newcourse->courseid);
                    fscanf(fp,"%d",&newcourse->credithour);
                    fscanf(fp,"%f",&tempfloat);
                    newcourse->score=tempfloat;
                    if(newcourse->score>=60.0)
                        newcourse->ispassed=1;
                    else
                        newcourse->ispassed=0;
                    fgetc(fp);
                    fgetc(fp);
                    fgetc(fp);
                    for(j=0;(ch=fgetc(fp))!='\n';j++)
                        newcourse->coursename[j]=ch;
                    newcourse->coursename[j]='\0';
                    newcourse->nextcourse=NULL;
                    if(i==1)
                    {
                        newstudent->courselist=newcourse;
                        listend=newstudent->courselist;
                    }
                    else
                    {
                        listend->nextcourse=newcourse;
                        listend=listend->nextcourse;
                    }
                }
                fscanf(fp,"=============================================");
                fgetc(fp);
                newstudent->nextstudent=NULL;
                listhead=addstudent(newstudent, listhead, issuccessful);
                if(*issuccessful)
                    (*counter)++;
                fgetc(fp);
            }
            fclose(fp);
            printf("\nImport from file %s successfully.\n",filename);
        }
    }
    return listhead;
}

void export(struct student *studentlist, int *counter)
{
    FILE *fp;
    struct student *currentstudent;
    struct course *currentcourse;
    int i,j,choose;
    char ch,tempch,filename[81],password[17];
    struct time currenttime;

    printf("\n%s\n%s","Please input the file name to export.","File Name: ");
    fflush(stdin);
    i=0;
    ch=getch();
    while(i==0||ch!='\r')
    {
        if(isprint(ch))
        {
            filename[i]=ch;
            printf("%c",ch);
            i++;
        }
        if(i>0&&ch=='\b')
        {
            printf("\b \b");
            i--;
        }
        ch=getch();
    }
    filename[i]='\0';
    printf("\n");
    while((fp=fopen(filename,"w"))==NULL)
    {
        printf("\n%s\n%s\n%s\n%s","Can't open the file, please choose the operation.","1-Retry","2-Cancel","Choice: ");
        fflush(stdin);
        i=0;
        choose=0;
        ch=getch();
        while(i==0||ch!='\r')
        {
            if(i<1&&(ch=='1'||ch=='2'))
            {
                choose=(int)ch-48;
                printf("%c",ch);
                i++;
            }
            if(i>0&&ch=='\b')
            {
                printf("\b \b");
                i--;
            }
            ch=getch();
        }
        printf("\n");
        switch(choose)
        {
            case 1: printf("\n%s\n%s","Please input the file name to export.","File Name: ");
                    fflush(stdin);
                    i=0;
                    ch=getch();
                    while(i==0||ch!='\r')
                    {
                        if(isprint(ch))
                        {
                            filename[i]=ch;
                            printf("%c",ch);
                            i++;
                        }
                        if(i>0&&ch=='\b')
                        {
                            printf("\b \b");
                            i--;
                        }
                        ch=getch();
                    }
                    filename[i]='\0';
                    printf("\n");
                    break;
            case 2: return;
        }
    }
    printf("\nDo you need to encrypt the file?(Y=yes, N=no): ");
    fflush(stdin);
    i=0;
    tempch=getch();
    while(i==0||tempch!='\r')
    {
        if(i<1&&(tempch=='y'||tempch=='Y'||tempch=='n'||tempch=='N'))
        {
            ch=(tempch=='y'||tempch=='Y'?'Y':'N');
            printf("%c",tempch);
            i++;
        }
        if(i>0&&tempch=='\b')
        {
            printf("\b \b");
            i--;
        }
        tempch=getch();
    }
    printf("\n");
    if(ch=='Y')
    {
        setpassword(password);
        gettime(&currenttime);
        j=currenttime.ti_hund;
        fprintf(fp,"e%d%c",j-50,(char)(strlen(password)+97));
        for(i=0;password[i]!='\0';i++)
            fprintf(fp,"%c",(char)((i+j)%

⌨️ 快捷键说明

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