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

📄 system.c

📁 学籍管理 包括1. 学生基本数据输入功能 2. 学生成绩输入功能 3. 学生数据和成绩的更新和删除功能 4. 按姓名/学号查找学生成绩功能 5. 按学号排序输出学生数据、各科成绩和平均成绩
💻 C
📖 第 1 页 / 共 5 页
字号:
            ch=getch();
        }
        newstudent->studentname[i]='\0';
        printf("\n");
        printf("\n%s\n%s","Please input the sex of the student.(F=female, M=male)","Sex(F/M): ");
        fflush(stdin);
        i=0;
        ch=getch();
        while(i==0||ch!='\r')
        {
            if(i<1&&(ch=='f'||ch=='F'||ch=='m'||ch=='M'))
            {
                newstudent->sex=(ch=='f'||ch=='F'?'F':'M');
                printf("%c",ch);
                i++;
            }
            if(i>0&&ch=='\b')
            {
                printf("\b \b");
                i--;
            }
            ch=getch();
        }
        printf("\n");
        printf("\n%s\n%s","Please input the birthday of the student.(Example: 1986-02-20)","Birthday: ");
        fflush(stdin);
        i=0;
        newstudent->birthday[4]=newstudent->birthday[7]='-';
        newstudent->birthday[10]='\0';
        getdate(&currentdate);
        ch=getch();
        while(i!=10||ch!='\r')
        {
            if(i<10&&isdigit(ch))
            {
                if(!(i==0&&(((int)ch-48)*1000>currentdate.da_year-10||((int)ch-48)*1000+999<currentdate.da_year-100))&&!(i==1&&((((int)newstudent->birthday[0]-48)*10+(int)ch-48)*100>currentdate.da_year-10||(((int)newstudent->birthday[0]-48)*10+(int)ch-48)*100+99<currentdate.da_year-100))&&!(i==2&&((((int)newstudent->birthday[0]-48)*100+((int)newstudent->birthday[1]-48)*10+(int)ch-48)*10>currentdate.da_year-10||(((int)newstudent->birthday[0]-48)*100+((int)newstudent->birthday[1]-48)*10+(int)ch-48)*10+9<currentdate.da_year-100))&&!(i==3&&(((int)newstudent->birthday[0]-48)*1000+((int)newstudent->birthday[1]-48)*100+((int)newstudent->birthday[2]-48)*10+(int)ch-48>currentdate.da_year-10||((int)newstudent->birthday[0]-48)*1000+((int)newstudent->birthday[1]-48)*100+((int)newstudent->birthday[2]-48)*10+(int)ch-48<currentdate.da_year-100))&&!(i==5&&ch!='0'&&ch!='1')&&!(i==6
                   &&(newstudent->birthday[5]=='0'&&ch=='0'||newstudent->birthday[5]=='1'&&ch!='0'&&ch!='1'&&ch!='2'))&&!(i==8&&(ch!='0'&&ch!='1'&&ch!='2'&&ch!='3'||ch=='3'&&newstudent->birthday[5]=='0'&&newstudent->birthday[6]=='2'))&&!(i==9&&(newstudent->birthday[8]=='0'&&ch=='0'||newstudent->birthday[8]=='2'&&newstudent->birthday[5]=='0'&&newstudent->birthday[6]=='2'&&!(newstudent->birthday[2]=='0'&&newstudent->birthday[3]=='0'&&(((int)newstudent->birthday[0]-48)*10+(int)newstudent->birthday[1]-48)%4==0||!(newstudent->birthday[2]=='0'&&newstudent->birthday[3]=='0')&&(((int)newstudent->birthday[2]-48)*10+(int)newstudent->birthday[3]-48)%4==0)&&ch=='9'||newstudent->birthday[8]=='3'&&(ch!='0'&&ch!='1'||ch=='1'&&(newstudent->birthday[6]=='4'||newstudent->birthday[6]=='6'||newstudent->birthday[6]=='9'||newstudent->birthday[5]=='1'&&newstudent->birthday[6]=='1')))))
                {
                    newstudent->birthday[i]=ch;
                    printf("%c",ch);
                    i++;
                }
                if(i==4||i==7)
                {
                    printf("-");
                    i++;
                }
            }
            if(i>0&&ch=='\b')
            {
                printf("\b \b");
                i--;
                if(i==4||i==7)
                {
                    printf("\b \b");
                    i--;
                }
            }
            ch=getch();
        }
        printf("\n");
        newstudent->age=currentdate.da_year-((int)newstudent->birthday[0]-48)*1000-((int)newstudent->birthday[1]-48)*100-((int)newstudent->birthday[2]-48)*10-((int)newstudent->birthday[3]-48);
        if(currentdate.da_mon<((int)newstudent->birthday[5]-48)*10+(int)newstudent->birthday[6]-48||currentdate.da_mon==((int)newstudent->birthday[5]-48)*10+(int)newstudent->birthday[6]-48&&currentdate.da_day<((int)newstudent->birthday[8]-48)*10+(int)newstudent->birthday[9]-48)
            newstudent->age--;
        printf("\nAge: %d\n",newstudent->age);
        printf("\n%s\n%s","Please input the identity card number of the student.(18 numbers)","Identity Card Number: ");
        fflush(stdin);
        i=0;
        newstudent->identity[6]=newstudent->birthday[0];
        newstudent->identity[7]=newstudent->birthday[1];
        newstudent->identity[8]=newstudent->birthday[2];
        newstudent->identity[9]=newstudent->birthday[3];
        newstudent->identity[10]=newstudent->birthday[5];
        newstudent->identity[11]=newstudent->birthday[6];
        newstudent->identity[12]=newstudent->birthday[8];
        newstudent->identity[13]=newstudent->birthday[9];
        ch=getch();
        while(i!=18||ch!='\r')
        {
            if(i<18&&isdigit(ch))
            {
                newstudent->identity[i++]=ch;
                printf("%c",ch);
            }
            if(i==6)
                while(i<=13)
                {
                    printf("%c",newstudent->identity[i]);
                    i++;
                }
            if(i>0&&ch=='\b')
            {
                printf("\b \b");
                i--;
                if(i==13)
                    while(i>=6)
                    {
                        printf("\b \b");
                        i--;
                    }
            }
            ch=getch();
        }
        newstudent->identity[i]='\0';
        printf("\n");
        printf("\n%s\n%s","Please input the province which the student comes from.","Province: ");
        fflush(stdin);
        i=0;
        ch=getch();
        while(i==0||ch!='\r')
        {
            if(i<20&&(isalpha(ch)||i!=0&&(ch=='\''||ch=='.'||ch=='-'||ch==' ')))
            {
                newstudent->province[i++]=ch;
                printf("%c",ch);
            }
            if(i>0&&ch=='\b')
            {
                printf("\b \b");
                i--;
            }
            ch=getch();
        }
        newstudent->province[i]='\0';
        printf("\n");
        printf("\n%s\n%s","Please input the city which the student comes from.","City: ");
        fflush(stdin);
        i=0;
        ch=getch();
        while(i==0||ch!='\r')
        {
            if(i<20&&(isalpha(ch)||i!=0&&(ch=='\''||ch=='.'||ch=='-'||ch==' ')))
            {
                newstudent->city[i++]=ch;
                printf("%c",ch);
            }
            if(i>0&&ch=='\b')
            {
                printf("\b \b");
                i--;
            }
            ch=getch();
        }
        newstudent->city[i]='\0';
        printf("\n");
        printf("\n%s\n%s","Please input the address of the student.","Address: ");
        fflush(stdin);
        i=0;
        ch=getch();
        while(i==0||ch!='\r')
        {
            if(i<50&&(isalpha(ch)||i!=0&&(isdigit(ch)||ch=='\''||ch=='.'||ch=='-'||ch==' ')))
            {
                newstudent->address[i++]=ch;
                printf("%c",ch);
            }
            if(i>0&&ch=='\b')
            {
                printf("\b \b");
                i--;
            }
            ch=getch();
        }
        newstudent->address[i]='\0';
        printf("\n");
        printf("\n%s\n%s","Please input the college which the student is in.","College: ");
        fflush(stdin);
        i=0;
        ch=getch();
        while(i==0||ch!='\r')
        {
            if(i<40&&(isalpha(ch)||i!=0&&(ch=='\''||ch=='.'||ch=='-'||ch==' ')))
            {
                newstudent->college[i++]=ch;
                printf("%c",ch);
            }
            if(i>0&&ch=='\b')
            {
                printf("\b \b");
                i--;
            }
            ch=getch();
        }
        newstudent->college[i]='\0';
        printf("\n");
        printf("\n%s\n%s","Please input the department which the student is in.","Department: ");
        fflush(stdin);
        i=0;
        ch=getch();
        while(i==0||ch!='\r')
        {
            if(i<40&&(isalpha(ch)||i!=0&&(ch=='\''||ch=='.'||ch=='-'||ch==' ')))
            {
                newstudent->department[i++]=ch;
                printf("%c",ch);
            }
            if(i>0&&ch=='\b')
            {
                printf("\b \b");
                i--;
            }
            ch=getch();
        }
        newstudent->department[i]='\0';
        printf("\n");
        printf("\n%s\n%s","Please input the number of courses which the student takes.","Number Of Courses: ");
        fflush(stdin);
        i=0;
        newstudent->numofcourses=0;
        ch=getch();
        while(i==0||ch!='\r')
        {
            if(i<2&&isdigit(ch))
            {
                newstudent->numofcourses=newstudent->numofcourses*10+(int)ch-48;
                printf("%c",ch);
                i++;
            }
            if(i>0&&ch=='\b')
            {
                newstudent->numofcourses/=10;
                printf("\b \b");
                i--;
            }
            ch=getch();
        }
        printf("\n");
        newstudent->passedcourses=0;
        newstudent->totalcredithour=0;
        newstudent ->passedcredithour=0;
        newstudent->averagescore=0.0;
        newstudent->courselist=NULL;
        for(i=1;i<=newstudent->numofcourses;)
        {
            printf("\n%s %d\n","Please input the information of Course",i);
            newstudent->courselist=addcourse(creatcourse(studentlist, newstudent->courselist, issuccessful), newstudent->courselist);
            if(done)
                i++;
            else
                newstudent->numofcourses--;
        }
        for(p=newstudent->courselist;p!=NULL;p=p->nextcourse)
        {
            if(p->ispassed)
            {
                newstudent->passedcourses++;
                newstudent->passedcredithour+=p->credithour;
            }
            newstudent->totalcredithour+=p->credithour;
            newstudent->averagescore+=p->score*p->credithour;
        }
        if(newstudent->totalcredithour!=0)
            newstudent->averagescore/=newstudent->totalcredithour;
        newstudent->nextstudent=NULL;
        return newstudent;
    }
}

struct student *changestudent(struct student *currentstudent, struct student *listhead)
{
    int i,choose;
    long id;
    char ch;
    struct date currentdate;
    
    do
    {
        printf("\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s","Please choose the operation."," 1-Change the student ID"," 2-Change the student name"," 3-Change the sex of the student"," 4-Change the birthday of the student"," 5-Change the identity card number of the student"," 6-Change the province which the student comes from"," 7-Change the city which the student comes from"," 8-Change the address of the student"," 9-Change the college which the student is in","10-Change the department which the student is in","11-Return","Choice: ");
        fflush(stdin);
        i=0;
        choose=0;
        ch=getch();
        while(i==0||ch!='\r')
        {
            if(i<2&&isdigit(ch)&&!(i==0&&ch=='0')&&!(i==1&&(choose!=1||choose&&ch!='0'&&ch!='1')))
            {
                choose=choose*10+(int)ch-48;
                printf("%c",ch);
                i++;
            }
            if(i>0&&ch=='\b')
            {
                choose/=10;
                printf("\b \b");
                i--;
            }
            ch=getch();
        }
        printf("\n");
        switch(choose)
        {
            case 1: printf("\n%s\n%s","Please input the new student ID.","New Student ID: ");
                    fflush(stdin);
                    i=0;
                    id=0;
                    ch=getch();
                    while(i==0||ch!='\r')
                    {
                        if(i<9&&isdigit(ch))
                        {
                            id=id*10+(int)ch-48;
                            printf("%c",ch);
                            i++;
                        }
                        if(i>0&&ch=='\b')
                        {
                            id/=10;
                            printf("\b \b");
                            i--;
                        }
                        ch=getch();
                    }
                    printf("\n");
                    listhead=chastuid(currentstudent, id, listhead);
                    break;
            case 2: printf("\n%s\n%s","Please input the new student name.","New Student Name: ");
                    fflush(stdin);
                    i=0;
                    ch=getch();
                    while(i==0||ch!='\r')
                    {
                        if(i<23&&(isalpha(ch)||i!=0&&ch==' '))
                        {
                            currentstudent->studentname[i++]=ch;
                            printf("%c",ch);
                        }
                        if(i>0&&ch=='\b')
                        {
                            printf("\b \b");
                            i--;
                        }
                        ch=getch();
                    }
                    currentstudent->studentname[i]='\0';
                    printf("\n");
                    break;
            case 3: printf("\n%s\n%s","Please input the new sex of the student.(F=female, M=male)","New Sex(F/M): ");
                    fflush(stdin);
                    i=0;
                    ch=getch();
                    while(i==0||ch!='\r')
                    {
                        if(i<1&&(ch=='f'||ch=='F'||ch=='m'||ch=='M'))
                        {
                            currentstudent->sex=(ch=='f'||ch=='F'?'F':'M');
                            printf("%c",ch);
                            i++;
                        }
                        if(i>0&&ch=='\b')
                        {

⌨️ 快捷键说明

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