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

📄 system.c

📁 学籍管理 包括1. 学生基本数据输入功能 2. 学生成绩输入功能 3. 学生数据和成绩的更新和删除功能 4. 按姓名/学号查找学生成绩功能 5. 按学号排序输出学生数据、各科成绩和平均成绩
💻 C
📖 第 1 页 / 共 5 页
字号:
                            printf("\b \b");
                            i--;
                        }
                            ch=getch();
                    }
                    printf("\n");
                    break;
            case 4: printf("\n%s\n%s","Please input the new birthday of the student.(Example: 1986-02-20)","New Birthday: ");
                    fflush(stdin);
                    i=0;
                    currentstudent->birthday[4]=currentstudent->birthday[7]='-';
                    currentstudent->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)currentstudent->birthday[0]-48)*10+(int)ch-48)*100>currentdate.da_year-10||(((int)currentstudent->birthday[0]-48)*10+(int)ch-48)*100+99<currentdate.da_year-100))&&!(i==2&&((((int)currentstudent->birthday[0]-48)*100+((int)currentstudent->birthday[1]-48)*10+(int)ch-48)*10>currentdate.da_year-10||(((int)currentstudent->birthday[0]-48)*100+((int)currentstudent->birthday[1]-48)*10+(int)ch-48)*10+9<currentdate.da_year-100))&&!(i==3&&(((int)currentstudent->birthday[0]-48)*1000+((int)currentstudent->birthday[1]-48)*100+((int)currentstudent->birthday[2]-48)*10+(int)ch-48>currentdate.da_year-10||((int)currentstudent->birthday[0]-48)*1000+((int)currentstudent->birthday[1]-48)*100+((int)currentstudent->birthday[2]-48)*10+(int)ch-48<currentdate.da_year-100))
                               &&!(i==5&&ch!='0'&&ch!='1')&&!(i==6&&(currentstudent->birthday[5]=='0'&&ch=='0'||currentstudent->birthday[5]=='1'&&ch!='0'&&ch!='1'&&ch!='2'))&&!(i==8&&(ch!='0'&&ch!='1'&&ch!='2'&&ch!='3'||ch=='3'&&currentstudent->birthday[5]=='0'&&currentstudent->birthday[6]=='2'))&&!(i==9&&(currentstudent->birthday[8]=='0'&&ch=='0'||currentstudent->birthday[8]=='2'&&currentstudent->birthday[5]=='0'&&currentstudent->birthday[6]=='2'&&!(currentstudent->birthday[2]=='0'&&currentstudent->birthday[3]=='0'&&(((int)currentstudent->birthday[0]-48)*10+(int)currentstudent->birthday[1]-48)%4==0||!(currentstudent->birthday[2]=='0'&&currentstudent->birthday[3]=='0')&&(((int)currentstudent->birthday[2]-48)*10+(int)currentstudent->birthday[3]-48)%4==0)&&ch=='9'||currentstudent->birthday[8]=='3'&&(ch!='0'&&ch!='1'||ch=='1'&&(currentstudent->birthday[6]=='4'
                               ||currentstudent->birthday[6]=='6'||currentstudent->birthday[6]=='9'||currentstudent->birthday[5]=='1'&&currentstudent->birthday[6]=='1')))))
                            {
                                currentstudent->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();
                    }
                    currentstudent->age=currentdate.da_year-((int)currentstudent->birthday[0]-48)*1000-((int)currentstudent->birthday[1]-48)*100-((int)currentstudent->birthday[2]-48)*10-((int)currentstudent->birthday[3]-48);
                    if(currentdate.da_mon<((int)currentstudent->birthday[5]-48)*10+(int)currentstudent->birthday[6]-48||currentdate.da_mon==((int)currentstudent->birthday[5]-48)*10+(int)currentstudent->birthday[6]-48&&currentdate.da_day<((int)currentstudent->birthday[8]-48)*10+(int)currentstudent->birthday[9]-48)
                        currentstudent->age--;
                    currentstudent->identity[6]=currentstudent->birthday[0];
                    currentstudent->identity[7]=currentstudent->birthday[1];
                    currentstudent->identity[8]=currentstudent->birthday[2];
                    currentstudent->identity[9]=currentstudent->birthday[3];
                    currentstudent->identity[10]=currentstudent->birthday[5];
                    currentstudent->identity[11]=currentstudent->birthday[6];
                    currentstudent->identity[12]=currentstudent->birthday[8];
                    currentstudent->identity[13]=currentstudent->birthday[9];
                    printf("\n");
                    break;
            case 5: printf("\n%s\n%s","Please input the new identity card number of the student.(18 numbers)","New Identity Card Number: ");
                    fflush(stdin);
                    i=0;
                    ch=getch();
                    while(i!=18||ch!='\r')
                    {
                        if(i<18&&isdigit(ch))
                        {
                            currentstudent->identity[i++]=ch;
                            printf("%c",ch);
                        }
                        if(i==6)
                            while(i<=13)
                            {
                                printf("%c",currentstudent->identity[i]);
                                i++;
                            }
                        if(i>0&&ch=='\b')
                        {
                            printf("\b \b");
                            i--;
                            if(i==13)
                                while(i>=6)
                                {
                                    printf("\b \b");
                                    i--;
                                }
                        }
                        ch=getch();
                    }
                    currentstudent->identity[i]='\0';
                    printf("\n");
                    break;
            case 6: printf("\n%s\n%s","Please input the new province which the student comes from.","New Province: ");
                    fflush(stdin);
                    i=0;
                    ch=getch();
                    while(i==0||ch!='\r')
                    {
                        if(i<20&&(isalpha(ch)||i!=0&&(ch=='\''||ch=='.'||ch=='-'||ch==' ')))
                        {
                            currentstudent->province[i++]=ch;
                            printf("%c",ch);
                        }
                        if(i>0&&ch=='\b')
                        {
                            printf("\b \b");
                            i--;
                        }
                        ch=getch();
                    }
                    currentstudent->province[i]='\0';
                    printf("\n");
                    break;
            case 7: printf("\n%s\n%s","Please input the new city which the student comes from.","New City: ");
                    fflush(stdin);
                    i=0;
                    ch=getch();
                    while(i==0||ch!='\r')
                    {
                        if(i<20&&(isalpha(ch)||i!=0&&(ch=='\''||ch=='.'||ch=='-'||ch==' ')))
                        {
                            currentstudent->city[i++]=ch;
                            printf("%c",ch);
                        }
                        if(i>0&&ch=='\b')
                        {
                            printf("\b \b");
                            i--;
                        }
                        ch=getch();
                    }
                    currentstudent->city[i]='\0';
                    printf("\n");
                    break;
            case 8: printf("\n%s\n%s","Please input the new address of the student.","New 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==' ')))
                        {
                            currentstudent->address[i++]=ch;
                            printf("%c",ch);
                        }
                        if(i>0&&ch=='\b')
                        {
                            printf("\b \b");
                            i--;
                        }
                        ch=getch();
                    }
                    currentstudent->address[i]='\0';
                    printf("\n");
                    break;
            case 9: printf("\n%s\n%s","Please input the new college which the student is in.","New College: ");
                    fflush(stdin);
                    i=0;
                    ch=getch();
                    while(i==0||ch!='\r')
                    {
                        if(i<40&&(isalpha(ch)||i!=0&&(ch=='\''||ch=='.'||ch=='-'||ch==' ')))
                        {
                            currentstudent->college[i++]=ch;
                            printf("%c",ch);
                        }
                        if(i>0&&ch=='\b')
                        {
                            printf("\b \b");
                            i--;
                        }
                        ch=getch();
                    }
                    currentstudent->college[i]='\0';
                    printf("\n");
                    break;
            case 10:printf("\n%s\n%s","Please input the new department which the student is in.","New Department: ");
                    fflush(stdin);
                    i=0;
                    ch=getch();
                    while(i==0||ch!='\r')
                    {
                        if(i<40&&(isalpha(ch)||i!=0&&(ch=='\''||ch=='.'||ch=='-'||ch==' ')))
                        {
                            currentstudent->department[i++]=ch;
                            printf("%c",ch);
                        }
                        if(i>0&&ch=='\b')
                        {
                            printf("\b \b");
                            i--;
                        }
                        ch=getch();
                    }
                    currentstudent->department[i]='\0';
                    printf("\n");
                    break;
            case 11:break;
        }
    }
    while(choose!=11);
    return listhead;
}

struct student *chastuid(struct student *currentstudent, long newid, struct student *listhead)
{
    struct student *p1,*p2,*followstudent;
    
    if(newid!=currentstudent->studentid)
    {
        for(p1=listhead;p1!=NULL;p1=p1->nextstudent)
            if(newid==p1->studentid)
            {
                printf("\n%s %ld %s\n","Student ID",newid,"has existed. Cann't change the source student ID to an existed ID.");
                break;
            }
        if(p1==NULL)
        {
            if(currentstudent==listhead)
                listhead=listhead->nextstudent;
            else
            {
                for(followstudent=listhead;followstudent->nextstudent!=currentstudent;followstudent=followstudent->nextstudent);
                followstudent->nextstudent=currentstudent->nextstudent;
            }
            p1=listhead;
            while(newid>p1->studentid&&p1->nextstudent!=NULL)
            {
                p2=p1;
                p1=p1->nextstudent;
            }
            if(newid<=p1->studentid)
                if(listhead==p1)
                {
                    listhead=currentstudent;
                    currentstudent->nextstudent=p1;
                }
                else
                {
                    p2->nextstudent=currentstudent;
                    currentstudent->nextstudent=p1;
                }
            else
            {
                p1->nextstudent=currentstudent;
                currentstudent->nextstudent=NULL;
            }
            printf("\n%s %ld %s %ld %s\n","Change student ID",currentstudent->studentid,"to",newid,"successfully.");
            currentstudent->studentid=newid;
        }
    }
    return listhead;
}

struct course *chacouid(struct student *thisstudent, struct course *currentcourse, int newid, struct student *studentlist)
{
    struct student *currentstudent;
    struct course *p1,*p2,*followcourse,*tempcourse;
    int i,isfound=0;
    char ch;
    
    if(newid!=currentcourse->courseid)
    {
        for(p1=thisstudent->courselist;p1!=NULL;p1=p1->nextcourse)
            if(newid==p1->courseid)
            {
                printf("\n%s %d %s\n","Course ID",newid,"has existed. Cann't change the source course ID to an existed ID.");
                break;
            }
        if(p1==NULL)
        {
            if(currentcourse==thisstudent->courselist)
                thisstudent->courselist=thisstudent->courselist->nextcourse;
            else
            {
                for(followcourse=thisstudent->courselist;followcourse->nextcourse!=currentcourse;followcourse=followcourse->nextcourse);
                followcourse->nextcourse=currentcourse->nextcourse;
            }
            p1=thisstudent->courselist;
            while(newid>p1->courseid&&p1->nextcourse!=NULL)
            {
                p2=p1;
                p1=p1->nextcourse;
            }
            if(newid<=p1->courseid)
                if(thisstudent->courselist==p1)
                {
                    thisstudent->courselist=currentcourse;
                    currentcourse->nextcourse=p1;
                }
                else
                {
                    p2->nextcourse=currentcourse;
                    currentcourse->nextcourse=p1;
                }
            else
            {
                p1->nextcourse=currentcourse;
                currentcourse->nextcourse=NULL;
            }
            printf("\n%s %d %s %d %s\n","Change course ID",currentcourse->courseid,"to",newid,"successfully.");
            currentcourse->courseid=newid;
            for(currentstudent=studentlist;currentstudent!=NULL;currentstudent=currentstudent->nextstudent)
            {
                for(tempcourse=currentstudent->courselist;tempcourse!=NULL;tempcourse=tempcourse->nextcourse)
                    if(currentstudent!=thisstudent&&currentcourse->courseid==tempcourse->courseid)
                    {
                        isfound=1;
                        break;
                    }
                if(isfound)
                    break;
            }
            if(!isfound)
            {
                printf("\n%s\n%s\n%s","This is a new course.","Please input the course name.","Course Name: ");
                fflush(stdin);
                i=0;
                ch=getch();
                while(i==0||ch!='\r')
                {
                    if(i<23&&(isalpha(ch)||i!=0&&(isdigit(ch)||ch=='\''||ch=='.'||ch=='-'||ch==' ')))
                    {
                        currentcourse->coursename[i++]=ch;
                        printf("%c",ch);
                    }
                    if(i>0&&ch=='\b')
                    {
                        printf("\b \b");
                        i--;
                    }
                    ch=getch();
                }
                currentcourse->coursename[i]='\0';
                printf("\n");
                thisstudent->averagescore*=thisstudent->totalcredithour;
                thisstudent->totalcredithour-=currentcourse->credithour;
                thisstudent->averagescore-=currentcourse->score*currentcourse->credithour;
                if(currentcourse->ispassed)
                    thisstudent->passedcourses-=currentcourse->credithour;
                printf("\n%s\n%s","Please input the credit hour of the course.(1~12)","Credit Hour: ");
                fflush(stdin);
                i=0;
                currentcourse->credithour=0;
                ch=getch();
                while(i==0||ch!='\r')
                {
                    if(i<2&&isdigit(ch)&&!(i==0&&ch=='0')&&!(i==1&&(currentcourse->credithour!=1||currentcourse->credithour==1&&ch!='0'&&ch!='1'&&ch!='2')))
                    {
                        currentcourse->credithour=currentcourse->credithour*10+(int)ch-48;
                        printf("%c",ch);
                        i++;

⌨️ 快捷键说明

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