| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 288 人关注过本帖
标题:谁帮我看看这个学生管理有什么可以改进和改正的地方啊?
只看楼主 加入收藏
左岸阳光
Rank: 1
等 级:新手上路
帖 子:3
专家分:0
注 册:2011-3-20
收藏
 问题点数:0 回复次数:2 
谁帮我看看这个学生管理有什么可以改进和改正的地方啊?

fread 总是多读出来一组数据(乱码)。。。


#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <conio.h>
struct basmes
{
    char name[20];
    char sex;
    int id;
    char stuclass[20];
    struct basmes *next;
};
struct markmes
{
    char name[20];
    int id;
    float math;
    float english;
    float C;
    int reward;
    struct markmes *next;
};
typedef struct basmes base;
typedef struct markmes mark;
void mainmenu(base *head_1,mark *head_2,FILE *fp1,FILE *fp2);
void password(void);
int menu(void);
void searchmenu(base *head_1);
base *addstudent(base *head_1);
void delmenu(base *head_1);
void changemenu(base *head_1);
base* lookover(base *head_1);
void searchmarkmenu(mark *head_2);
mark* addmark(mark *head_2);
void changemarkmenu(mark *head_2);
mark* lookovermark(mark *head_2);
base* readfilestu(base *head_1,FILE *fp1);
mark* readfilemark(mark *head_2,FILE *fp2);
void savefilestu(base *head_1,FILE *fp1);
void savefilemark(mark *head_2,FILE *fp2);
void namesearchstu(base *head_1,char name[]);
void idsearchstu(base *head_1,int id);
void classsearchstu(base *head_1,char stuclass[]);
void sexsearchstu(base *head_1,char sex);
void searchmarkmenu(mark *head_2);
void namesearchmark(mark *head_2,char name[]);
void idsearchmark(mark *head_2,int id);
void mathsearchmark(mark *head_2,float low,float high);
void englishsearchmark(mark *head_2,float low,float high);
void csearchmark(mark *head_2,float low,float high);
void delmenu(base *head_1);
void namedelstu(base *head_1,char name[]);
base* iddelstu(base *head_1,int id);
void delmarkmenu(mark *head_2);
mark* iddelmark(mark *head_2,int id);
void namedelmark(mark *head_2,char name[]);
void scholarshipmenu(mark *head_2);
void lookoverscholarship(mark *head_2);
void idscholarship(mark *head_2,int id);
mark *figureout(mark *head_2);
void changemenu(base *head_1);
void namechange(base *head_1,int id,char name[]);
void classchange(base *head_1,int id,char stuclass[]);
void sexchange(base *head_1,int id,char sex);
void changemarkmenu(mark *head_2);
void englishchange(mark *head_2,int id,float english);
void Cchange(mark *head_2,int id,float C);
void mathchange(mark *head_2,int id,float maths);
void main()
{
    base *head_1=(base *)malloc(sizeof(base));
    mark *head_2=(mark *)malloc(sizeof(mark));
    FILE *fp1;
    FILE *fp2;
    head_1->next=NULL;
    head_2->next=NULL;
    password();
    system("cls");
    printf("\t欢迎来到学生信息管理系统。\n");
    mainmenu(head_1,head_2,fp1,fp2);
}
//先编写菜单函数
void password(void)
{
    int k,i;
    char print[10]={0};
    char password[]="2811012";
    k=3;
    while((k--)>=1)
    {
        printf("你还有%d次机会,请输入密码:",k+1);
        for(i=0;i<7;i++)
        {
            print[i]=getch();
            printf("*");        
        }
        getch();
        if(strcmp(print,password)==0)
            {
                printf("\n密码正确.\n");
                return;
            }
    }
    printf("密码输入错误!!退出。");
    exit(0);
}
void mainmenu(base *head_1,mark *head_2,FILE *fp1,FILE *fp2)
{
    int getchoose,choose,choose_1;
    while(1)
    {
        getchoose=menu();
        switch(getchoose)
        {
        case 1:
            while(1)
            {
                 printf("            学生基本信息管理\n");
                 printf("            1 查找信息\n");
                printf("            2 添加信息\n");
                printf("            3 删除信息\n");
                printf("            4 修改信息\n");
                 printf("            5 遍历信息\n");
                printf("            6 返回\n");
                printf("请选择\n");
                 scanf("%d",&choose);
                 if(choose==1)
                {
                    searchmenu(head_1);
                }
                else if(choose==2)
                {
                    head_1=addstudent(head_1);
                }
                  else if(choose==3)
                {
                    delmenu(head_1);
                }
                else if(choose==4)
                {
                    changemenu(head_1);
                }
                else if(choose==5)
                {
                    head_1=lookover(head_1);
                }
                else if(choose==6)
                {
                    break;
                }
                else
                {
                    printf("输入错误");
                    printf("重新输入:\n");
                }
            }
            break;


        case 2:
            while(1)
            {
                printf("            学生成绩信息管理\n");
                printf("            1 查找成绩信息\n");
                printf("            2 添加成绩信息\n");
                printf("            3 删除成绩信息\n");
                 printf("            4 修改成绩信息\n");
                printf("            5 遍历成绩信息\n");
                printf("            6 奖学金信息\n");
                printf("            7 返回\n");
                printf("请选择\n");
                scanf("%d",&choose);
                if(choose==1)
                {
                     searchmarkmenu(head_2);
                }
                else if(choose==2)
                {
                    head_2=addmark(head_2);
                }
                else if(choose==3)
                {
                    delmarkmenu(head_2);
                }
                else if(choose==4)
                {
                    changemarkmenu(head_2);//只改分数
                }
                 else if(choose==5)
                {
                     head_2=lookovermark(head_2);
                }
                else if(choose==6)
                {
                    scholarshipmenu(head_2);
                }
                else if(choose==7)
                {
                     break;
                }
                else
                {
                    printf("输入错误.");
                    printf("重新输入:\n");
                }
            }
            break;
        case 3:
            while(1)
            {
                   printf("         \n文件管理\n");
                 printf("         1 从文件读取信息;\n");
                 printf("         2 保存学生信息到文件;\n");
                 printf("         3 返回。\n");
                 printf("请选择:");
                 scanf("%d",&choose);
                 if(choose==1)
                {
                    printf("           1 读取学生基本信息;\n");
                    printf("           2 读取学生成绩信息;\n");
                     printf("           输入其他数字返回。");
                     printf("请选择:\n");
                    scanf("%d",&choose_1);
                    if(choose_1==1)
                    {
                         head_1=readfilestu(head_1,fp1);
                    }
                    else if(choose_1==2)
                    {
                        head_2=readfilemark(head_2,fp2);
                    }
                }
                else if(choose==2)
                {
                    printf("    1 保存学生基本信息\n");
                    printf("    2 保存学生成绩信息\n");
                    printf("    输入其他数字返回。\n");
                     printf("请选择:\n");
                     scanf("%d",&choose_1);
                    if(choose_1==1)
                    {
                         savefilestu(head_1,fp1);
                    }
                    else if(choose_1==2)
                    {
                        savefilemark(head_2,fp2);
                    }
                }
                 else if(choose==3)
                {
                    break;
                }
                else
                {
                    printf("输入错误,重新输入。\n");
                }
            }
            break;
        case 4:
            return;
            break;
        }
    }
}
int menu(void)
{
    int choose=1;//先让choose 为1,进入循环。
    while(choose==1||choose==2||choose==3||choose==4)
    {
        printf("**********************************************\n");
        printf("*            学生信息管理系统                *\n");
        printf("*          1 学生基本信息管理                *\n");
        printf("*          2 学生成绩信息管理                *\n");
        printf("*          3 文件管理                        *\n");
        printf("*          4 退出                            *\n");
        printf("**********************************************\n");
        printf("请选择\n");
        scanf("%d",&choose);
        if(choose!=1&&choose!=2&&choose!=3&&choose!=4)
        {
            printf("输入错误,请重新输入!\n");
            choose=1;//让choose=1,重新进入循环
            continue;
        }
        return choose;
    }
}
void searchmenu(base *head_1)
{
    char name[20],stuclass[20],sex;
    int choose_2,id;
    int i=1;
    while(i!=0)
    {
        printf("\n*************************************************\n");
        printf("                      查找方式\n");
        printf("                     1 姓名查找;\n");
        printf("                     2 学号查找;\n");
        printf("                     3 班级查找;\n");
        printf("                     4 性别查找;\n");
        printf("                     5 返回;\n");
        printf("  *************************************************\n");
        printf("请选择\n");
        scanf("%d",&choose_2);
        printf("\n");
        switch(choose_2)
        {
        case 1:
            fflush(stdin);
            printf("请输入姓名:");
            gets(name);
            namesearchstu(head_1,name);
            fflush(stdin);
            printf("按任意键返回:");
            getch();
            break;
        case 2:
            printf("请输入学号:");
            scanf("%d",&id);
            idsearchstu(head_1,id);
            printf("按任意键返回:");
            getch();
            break;
        case 3:
            fflush(stdin);
            printf("请输入班级:");
            gets(stuclass);
            classsearchstu(head_1,stuclass);
            printf("按任意键返回:");
            getch();
            break;
        case 4:
            fflush(stdin);
            printf("请输入性别:");
            sex=getchar();
            sexsearchstu(head_1,sex);
            printf("按任意键返回:");
            getch();
            break;
        case 5:
            i=0;//让i=0,从而退出while
            break;
        default:
            printf("输入错误,重新输入。\n");
            break;
        }
    }
}
void searchmarkmenu(mark *head_2)
{   
    char name[20];
    int i,id,j;
    int choose_3,choose_3_1;
    float low,high;//分数区间
    i=j=1;
    while(i!=0)
    {
        printf("\n*************************************************\n");
        printf("                      查找方式\n");
        printf("                     1 姓名查找;\n");
        printf("                     2 学号查找;\n");
        printf("                     3 分数段查找;\n");
        printf("                     4 返回;\n");
        printf("  *************************************************\n");
        printf("请选择\n");
        scanf("%d",&choose_3);
        switch(choose_3)
        {
        case 1:
            fflush(stdin);
            printf("请输入姓名:");
            gets(name);
            namesearchmark(head_2,name);
            fflush(stdin);
            printf("按任意键返回:");
            getch();
            break;
        case 2:
            printf("请输入学号:");
            scanf("%d",&id);
            idsearchmark(head_2,id);
            fflush(stdin);
            printf("按任意键返回:");
            getch();
            break;
        case 3:
            while(i!=0)
            {
                printf("\n*****************************************************\n");
                 printf("                       1 数学成绩查询;\n");
                printf("                       2 英语成绩查询;\n");
                printf("                       3 C语言成绩查询;\n");
                printf("                       4 返回。 \n");
                printf("*********************************************************\n");
                printf("请输入\n");
                scanf("%d",&choose_3_1);
                switch(choose_3_1)
                {
                case 1:
                    printf("\n输入数学分数段(可相同):(格式如90 90)");
                    scanf("%f %f",&low,&high);
                    mathsearchmark(head_2,low,high);
                    fflush(stdin);
                    printf("按任意键返回");
                    getch();
                    break;
                case 2:
                    printf("\n输入英语分数段(可相同):(格式如90 90)");
                    scanf("%f %f",&low,&high);
                    englishsearchmark(head_2,low,high);
                    fflush(stdin);
                    printf("按任意键返回");
                    getch();
                    break;
                case 3:
                    printf("\n输入C分数段(可相同):(格式如90 90)");
                    scanf("%f %f",&low,&high);
                    csearchmark(head_2,low,high);
                    fflush(stdin);
                    printf("按任意键返回");
                    getch();
                    break;
                case 4:
                    i=0;
                    break;
                default:
                    printf("输入错误,重新输入。\n");
                    break;
                }
            }        
                break;
        case 4:
            i=0;
            break;
        default:
            printf("输入错误,重新输入。\n");
            break;
        }
    }
}
void delmenu(base *head_1)
{
    int choose_4;
    int i=1;
    char name[20]={0};
    int id;
    while(i)
    {
        printf("\n***********************************************************\n");
        printf("                    删除学生基本信息\n");
        printf("                  1 按学号删除;\n");
        printf("                  2 返回;\n");
        printf("  ***********************************************************\n");
        printf("请输入\n");
        scanf("%d",&choose_4);
        printf("\n");
        switch(choose_4)
        {
        case 1:
            printf("请输入学号:");
            scanf("%d",&id);
            head_1=iddelstu(head_1,id);
            fflush(stdin);
            printf("按任意键返回:");
            getch();
            break;
        case 2:
            i=0;
            break;
        default:
            printf("输入错误,重新输入。\n");
            break;
        }
    }
}
void delmarkmenu(mark *head_2)
{
    int choose_5;

    int i=1;
    char name[20]={0};
    int id;
    while(i)
    {
        printf("\n***********************************************************\n");
        printf("                   删除学生成绩信息\n");
        printf("                 1 按学号删除;\n");
        printf("                 2 返回;\n");
        printf("  ***********************************************************\n");
        printf("请输入\n");
        scanf("%d",&choose_5);
        printf("\n");
        switch(choose_5)
        {
        case 1:
            printf("请输入学号:");
            scanf("%d",&id);
            head_2=iddelmark(head_2,id);
            fflush(stdin);
            printf("按任意键返回:");
            getch();
            break;
        case 2:
            i=0;
            break;
        default:
            printf("输入错误,重新输入。\n");
            break;
        }
    }
}
void scholarshipmenu(mark *head_2)
{
    int i;
    int choose_6;
    int id;
    i=1;
    while(i!=0)
    {
        printf("\n******************************************************************\n");
        printf("                                  奖学金信息\n");
        printf("                                 1 遍历奖学金信息;\n");
        printf("                                 2 按学号查询奖学金信息;\n");
        printf("                                 3 计算奖学金; \n");
        printf("                                 4 返回;\n");
        printf("  ******************************************************************\n");
        printf("请选择:");
        scanf("%d",&choose_6);
        printf("\n");
        switch(choose_6)
        {
        case 1:
            lookoverscholarship(head_2);
            break;
        case 2:
            printf("\n请输入学号:");
            scanf("%d",&id);
            idscholarship(head_2,id);
            break;
        case 3:
            printf("正在计算奖学金。。。\n");
            head_2=figureout(head_2);
            break;
        case 4:
            i=0;
            break;
        default:
            printf("输入错误,重新输入。\n");
            break;
        }
    }
}
void changemenu(base *head_1)
{
    int choose_7;
    char name[20]={0};
    char sex;
    char stuclass[20];
    int id;
    int i=1;
    while(i)
    {
        printf("******************************************************************\n");
        printf("                             修改学生基本信息\n");
        printf("                            1 修改学生姓名;\n");
        printf("                            2 修改学生班级; \n");
        printf("                            3 修改学生性别;\n");
        printf("                            4 返回; \n");
        printf("******************************************************************\n");
        printf("请输入:");
        scanf("%d",&choose_7);
        switch(choose_7)
        {
        case 1:
            printf("请输入学生ID:");
            scanf("%d",&id);
            printf("输入姓名:");
            fflush(stdin);
            gets(name);
            namechange(head_1,id,name);
            break;
        case 2:
            printf("请输入学生ID:");
            scanf("%d",&id);
            printf("输入班级:");
            fflush(stdin);
            gets(stuclass);
            classchange(head_1,id,stuclass);
            break;
        case 3:
            printf("请输入学生ID:");
            scanf("%d",&id);
            printf("输入性别:");
            fflush(stdin);
            sex=getchar();
            sexchange(head_1,id,sex);
            break;
        case 4:
            i=0;
            break;
        default:
            printf("输入错误,重新输入。\n");
            break;
        }
    }
}
搜索更多相关主题的帖子: english 
2011-03-20 14:42
左岸阳光
Rank: 1
等 级:新手上路
帖 子:3
专家分:0
注 册:2011-3-20
收藏
得分:0 
void changemarkmenu(mark *head_2)
{
    int choose_8;
    float maths;
    float C;
    float english;
    int id;
    int i=1;
    while(i)
    {
        printf("******************************************************************\n");
        printf("                             修改学生成绩信息\n");
        printf("                            1 修改高数;\n");
        printf("                            2 修改C; \n");
        printf("                            3 修改英语;\n");
        printf("                            4 返回; \n");
        printf("******************************************************************\n");
        printf("请输入:");
        scanf("%d",&choose_8);
        switch(choose_8)
        {
        case 1:
            printf("请输入学生ID:");
            scanf("%d",&id);
            printf("输入数学成绩:");
            fflush(stdin);
            scanf("%f",&maths);
            mathchange(head_2,id,maths);
            break;
        case 2:
            printf("请输入学生ID:");
            scanf("%d",&id);
            printf("输入C成绩:");
            fflush(stdin);
            scanf("%f",&C);
            Cchange(head_2,id,C);
            break;
        case 3:
            printf("请输入学生ID:");
            scanf("%d",&id);
            printf("输入英语成绩:");
            fflush(stdin);
            scanf("%f",&english);
            englishchange(head_2,id,english);
            break;
        case 4:
            i=0;
            break;
        default:
            printf("输入错误,重新输入。\n");
            break;
        }
    }
}
base *addstudent(base *head_1)
{
    char name[20];
    char sex;
    char stuclass[20];
    int id;
    base *p,*tail=NULL;
    printf("\n请输入学生基本信息(当学号为0时停止输入)\n");
    printf("输入姓名 性别 班级 学号:格式如(liwen m  ruanxin1001 20103638)\n");
    scanf("%s %c %s %d",name,&sex,stuclass,&id);
    while(id)
    {
        p=(base *)malloc(sizeof(base));
           strcpy(p->name,name);
           p->sex=sex;
           strcpy(p->stuclass,stuclass);
           p->id=id;
           p->next=NULL;
        if(head_1->next==NULL)
        {
            head_1->next=tail=p;
        }
        else
        {
            tail=head_1->next;
            while(tail->next!=NULL)
            {
                tail=tail->next;
            }
            tail->next=p;
            tail=p;
        }
        printf("输入姓名 性别 班级 学号:格式如(liwen m  ruanxin1001 20103638)\n");
        scanf("%s %c %s %d",name,&sex,stuclass,&id);
    }
    return head_1;
}
mark* addmark(mark *head_2)
{
    char name[20];
    int id;
    float C,math,english;
    float sum=0;
    mark *p=NULL;
    mark *tail=NULL;
    printf("\n请输入学生基本信息(当学号为0时停止输入)\n");
    printf("输入姓名 学号 成绩 (C math english):格式如(liwen 20103638 90 90 90)\n");
    scanf("%s %d %f %f %f",name,&id,&C,&math,&english);
    while(id)
    {
        p=(mark *)malloc(sizeof(mark));
        strcpy(p->name,name);
           p->id=id;
        p->C=C;
           p->math=math;
           p->english=english;
        p->next=NULL;
        if(head_2->next==NULL)
        {
            head_2->next=tail=p;
        }
        else
        {
            tail=head_2->next;
            while(tail->next!=NULL)
            {
                tail=tail->next;
            }
            tail->next=p;
            tail=p;
        }
        printf("输入姓名 学号 成绩 (C math english):格式如(liwen 20103638 90 90 90)\n");
        scanf("%s %d %f %f %f",name,&id,&C,&math,&english);
    }
    return head_2;
}
base* lookover(base *head_1)
{
    base *p=head_1;
    if(p->next==NULL)
    {
        printf("学生信息为空!\n");
    }
    else
    {
        printf("**********************************************************\n");
        printf("           姓名   性别   学号     班级\n");
    }

    while(p->next!=NULL)
    {
        printf("          %s       %c    %d        %s\n",p->next->name,p->next->sex,p->next->id,p->next->stuclass );
        p=p->next;
    }
    return head_1;
}
mark* lookovermark(mark *head_2)
{
    mark *p=head_2;
    if(p->next==NULL)
    {
        printf("成绩信息为空!\n");
    }
    else
    {
        printf("************************************************************\n");
        printf("           姓名     学号    C语言   高数    英语\n");
    }
    while(p->next!=NULL)
    {
        printf("          %s        %d       %.2f   %.2f    %.2f \n",p->next->name,p->next->id,p->next->C,p->next->math,p->next->english);
        p=p->next;
    }
    return head_2;
}
void namesearchstu(base *head_1,char name[])
{
    base *p=head_1;
    printf("找到的信息如下:\n");
    printf("         姓名     性别    学号      班级 \n  ");
    while(p->next!=NULL)
    {
        if(strcmp(p->next->name,name)==0)
        {
            printf("         %s       %c     %d       %s\n",p->next->name,p->next->sex,p->next->id,p->next->stuclass);
        }
        p=p->next;
    }
    return ;
}
void idsearchstu(base *head_1,int id)
{
    base *p=head_1;
    printf("找到的信息如下:\n");
    printf("         姓名     性别    学号      班级 \n  ");
    while(p->next!=NULL)
    {
        if(p->next->id==id)
        {
            printf("         %s       %c     %d         %s\n",p->next->name,p->next->sex,p->next->id,p->next->stuclass);
        }
        p=p->next;
    }
    return ;
}
void classsearchstu(base *head_1,char stuclass[])
{
    base *p=head_1;
    printf("找到的信息如下:\n");
    printf("         姓名     性别    学号      班级 \n  ");
    while(p->next!=NULL)
    {
        if(strcmp(p->next->stuclass,stuclass)==0)
        {
            printf("         %s       %c       %d         %s\n",p->next->name,p->next->sex,p->next->id,p->next->stuclass);
        }
        p=p->next;
    }
    return ;
}
void sexsearchstu(base *head_1,char sex)
{
    base *p=head_1;
    printf("找到的信息如下:\n");
    printf("           姓名     性别    学号      班级 \n  ");
    while(p->next!=NULL)
    {
        if(p->next->sex==sex)
        {
            printf("           %s       %c     %d         %s\n",p->next->name,p->next->sex,p->next->id,p->next->stuclass);
        }
        p=p->next;
    }
    return ;
}
void namesearchmark(mark *head_2,char name[])
{
    mark *p=head_2;
    printf("找到的信息如下:\n");
    printf("   姓名     学号    C语言   高数    英语\n");
    while(p->next!=NULL)
    {
        if(strcmp(p->next->name,name)==0)
        {
            printf("  %s        %d       %.2f     %.2f       %.2f \n",p->next->name,p->next->id,p->next->C,p->next->math,p->next->english);
        }
        p=p->next;
    }
    return;
}
void idsearchmark(mark *head_2,int id)
{
    mark *p=head_2;
    printf("找到的信息如下:\n");
    printf("           姓名     学号    C语言   高数    英语\n");
    while(p->next!=NULL)
    {
        if(p->next->id==id)
        {
            printf("          %s        %d       %.2f     %.2f       %.2f \n",p->next->name,p->next->id,p->next->C,p->next->math,p->next->english);
            break;
        }
        p=p->next;
    }
    return;
}
vo        p=p->next;
    }
    return;
}id mathsearchmark(mark *head_2,float low,float high)
{
    mark *p=head_2;
    printf("找到的信息如下:\n");
    printf("           姓名     学号    C语言   高数    英语\n");
    while(p->next!=NULL)
    {
        if(p->next->math>=low&&p->next->math<=high)
        {
            printf("          %s        %d       %.2f     %.2f       %.2f \n",p->next->name,p->next->id,p->next->C,p->next->math,p->next->english);
        }
        p=p->next;
    }
    return;
}
void englishsearchmark(mark *head_2,float low,float high)
{
    mark *p=head_2;
    printf("找到的信息如下:\n");
    printf("           姓名     学号    C语言   高数    英语\n");
    while(p->next!=NULL)
    {
        if(p->next->english>=low&&p->next->english<=high)
        {
            printf("          %s        %d       %.2f     %.2f       %.2f \n",p->next->name,p->next->id,p->next->C,p->next->math,p->next->english);
        }
        p=p->next;
    }
    return;
}
void csearchmark(mark *head_2,float low,float high)
{
    mark *p=head_2;
    printf("找到的信息如下:\n");
    printf("           姓名     学号    C语言   高数    英语\n");
    while(p->next!=NULL)
    {
        if(p->next->C>=low&&p->next->C<=high)
        {
            printf("          %s        %d       %.2f     %.2f       %.2f \n",p->next->name,p->next->id,p->next->C,p->next->math,p->next->english);
        }
        p=p->next;
    }
    return;
}
base* iddelstu(base *head_1,int id)
{
    base *p,*q;
    p=head_1;
    if(p->next==NULL)
    {
        printf("基本信息为空\n");
        return head_1 ;
    }
    if(p->next->id==id)
    {
        p->next=p->next->next;
    }
    else
    {
        while(p->next->id!=id&&p->next->next!=NULL)
        {
            p=p->next;
            q=p->next;
        }   
        if(p->next->id==id&&p->next->next==NULL)
        {
            p->next=NULL;
        }
        else if(p->next->id!=id&&p->next->next==NULL)
        {
            printf("输入的学号不存在!\n");
        }
        else
        {
            p->next=q->next;
            free(q);

        }
    }
    return head_1;
}
mark* iddelmark(mark *head_2,int id)
{
    mark *p,*q;
    p=head_2;
    if(p->next==NULL)
    {
        printf("基本信息为空\n");
        return head_2 ;
    }
    if(p->next->id==id)
    {
        p->next=p->next->next;
    }
    else
    {
        while(p->next->id!=id&&p->next->next!=NULL)
        {
            p=p->next;
            q=p->next;
        }   
        if(p->next->id==id&&p->next->next==NULL)
        {
            p->next=NULL;
        }
        else if(p->next->id!=id&&p->next->next==NULL)
        {
            printf("输入的学号不存在!\n");
        }
        else
        {
            p->next=q->next;
            free(q);

        }
    }
    return head_2;
}
mark *figureout(mark *head_2)
{
    float sum[100];
    int i;
    mark *p=head_2;
    i=0;
    if(p->next==NULL)
    {
        printf("学生成绩信息为空!\n");
    }
    else
    {
        while(p->next!=NULL)
        {
            sum[i++]=p->next->C+p->next->english+p->next->math;
            p=p->next;
        }
    }
    p=head_2;
    i=0;
    while(p->next!=NULL)
    {
        if(sum[i]>=270)
        {
            p->next->reward=1000;
        }
        else if(sum[i]<270&&sum[i]>=255)
        {
            p->next->reward=500;
        }
        else
        {
            p->next->reward=0;
        }
        p=p->next;
    }
    return head_2;
}


void lookoverscholarship(mark *head_2)
{
    mark *p=head_2;
    printf("***************************************************\n");
    printf("                    奖学金信息如下:\n");
    printf("            姓名      学号       奖金\n" );
    for(;p->next!=NULL;p=p->next)
    {
        printf("        %s        %d        %d\n",p->next->name,p->next->id,p->next->reward);
    }
    return;
}
void idscholarship(mark *head_2,int id)
{
    mark *p=head_2;
    if(p->next==NULL)
    {
        printf("学生成绩信息为空。");
    }
    for(;p->next!=NULL&&p->next->id==id;p=p->next)
    {
        printf("该生奖学金为:%d\n",p->next->reward);
    }
    if(p!=head_2&&p->next==NULL)
    {
        printf("未找到该生.\n");
    }
    return;
}
base* readfilestu(base *head_1,FILE *fp1)
{
    int i;
    base *p=head_1;
    fp1=fopen("学生基本信息管理","r");
    if(!(fopen("学生基本信息管理","r")))
    {
        printf("文件打开失败.\n");
    }
    else
    {
        while(feof(fp1)==0)
        {
            p->next=(base *)malloc(sizeof(base));
            i=fread(p->next,sizeof(base),1,fp1);
            p=p->next;
        }
        p->next=NULL;
    }
    fclose(fp1);
    return head_1;
}
mark* readfilemark(mark *head_2,FILE *fp2)
{
    mark *p=head_2;
    fp2=fopen("学生成绩信息管理","r");
    if(!(fopen("学生成绩信息管理","r")))
    {
        printf("文件打开失败.\n");
    }
    else
    {
        p->next=(mark *)malloc(sizeof(mark));
        for(;feof(fp2)==0;p->next=(mark *)malloc(sizeof(mark)))
        {
            fread(p->next,sizeof(mark),1,fp2);
            p=p->next;
        }
        p->next=NULL;
    }
    fclose(fp2);
    return head_2;
}
void savefilestu(base *head_1,FILE *fp1)
{
    base *p=head_1->next;
    fp1=fopen("学生基本信息管理","w");
    if(!(fopen("学生基本信息管理","w")))
    {
        printf("文件打开失败.\n");
    }
    else
    {
        if(p==NULL)
        {
            printf("无学生信息。请添加学生信息。\n");
        }
        while(p!=NULL)
        {
            fwrite(p,sizeof(base),1,fp1);
            p=p->next;
        }
    }
    fclose(fp1);
}
void savefilemark(mark *head_2,FILE *fp2)
{
    mark *p=head_2->next;
    fp2=fopen("学生成绩信息管理","w");
    if(!(fopen("学生成绩信息管理","w")))
    {
        printf("文件打开失败.\n");
    }
    else
    {
        if(p==NULL)
        {
            printf("无学生信息。请添加学生信息。\n");
        }
        while(p!=NULL)
        {
            fwrite(p,sizeof(mark),1,fp2);
            p=p->next;
        }
    }
    fclose(fp2);
}
void namechange(base *head_1,int id,char name[])
{
    base *p=head_1->next;
    if(p==NULL)
    {
        printf("学生基本信息为空。\n");
    }
    while(p->id!=id&&p->next!=NULL)
    {
        p=p->next;
    }
    if(p->next==NULL&&p->id!=id)
    {
        printf("无此学号\n");
    }
    else
    {
        strcpy(p->name ,name);
    }   
    return ;
}
void classchange(base *head_1,int id,char stuclass[])
{
    base *p=head_1->next;
    if(p==NULL)
    {
        printf("学生基本信息为空。\n");
    }
    while(p->id!=id&&p->next!=NULL)
    {
        p=p->next;
    }
    if(p->next==NULL&&p->id!=id)
    {
        printf("无此学号\n");
    }
    else
    {
        strcpy(p->stuclass,stuclass);
    }   
}
void sexchange(base *head_1,int id,char sex)
{
    base *p=head_1->next;
    if(p==NULL)
    {
        printf("学生基本信息为空。\n");
    }
    while(p->id!=id&&p->next!=NULL)
    {
        p=p->next;
    }
    if(p->next==NULL&&p->id!=id)
    {
        printf("无此学号\n");
    }
    else
    {
        p->sex=sex;   
    }        
}
void englishchange(mark *head_2,int id,float english)
{
    mark *p=head_2->next;
    if(p==NULL)
    {
        printf("学生基本信息为空。\n");
    }
    while(p->id!=id&&p->next!=NULL)
    {
        p=p->next;
    }
    if(p->next==NULL&&p->id!=id)
    {
        printf("无此学号\n");
    }
    else
    {
        p->english=english;
    }
   
}
void Cchange(mark *head_2,int id,float C)
{
    mark *p=head_2->next;
    if(p==NULL)
    {
        printf("学生基本信息为空。\n");
    }
    while(p->id!=id&&p->next!=NULL)
    {
        p=p->next;
    }
    if(p->next==NULL&&p->id!=id)
    {
        printf("无此学号\n");
    }
    else
    {
        p->C=C;
    }
   
}
void mathchange(mark *head_2,int id,float maths)
{
    mark *p=head_2->next;
    if(p==NULL)
    {
        printf("学生基本信息为空。\n");
    }
    while(p->id!=id&&p->next!=NULL)
    {
        p=p->next;
    }
    if(p->next==NULL&&p->id!=id)
    {
        printf("无此学号\n");
    }
    else
    {
        p->math=maths;
    }   
}
2011-03-20 14:42
yq1544638566
Rank: 1
等 级:新手上路
帖 子:14
专家分:7
注 册:2011-3-1
收藏
得分:0 
新手
2011-03-20 14:58
快速回复:谁帮我看看这个学生管理有什么可以改进和改正的地方啊?
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.022391 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved