| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1122 人关注过本帖, 1 人收藏
标题:自己写的一个关于学生信息管理系统的小程序,欢迎围观
取消只看楼主 加入收藏
阿维
Rank: 2
来 自:china
等 级:论坛游民
帖 子:30
专家分:43
注 册:2014-11-10
结帖率:100%
收藏(1)
 问题点数:0 回复次数:4 
自己写的一个关于学生信息管理系统的小程序,欢迎围观
学生成绩管理系统


题目与要求:

某班有最多不超过30人(具体人数由键盘输入)参加期末考试,最多不超过6门(具体门数由键盘输入)。
1.    从文件读入每个学生个人信息和成绩信息,可以由键盘输入文件名。读入成功提示读入学生记录的个数,不成功提示相应出错信息。
2.    增量式手动录入每个学生的学号、姓名和各科考试成绩。不考虑中文姓名,但需要考虑重名情况下的处理,学生的学号是唯一的。
3.    计算每门课程的总分和平均分;
4.    计算每个学生的总分和平均分;
5.    按每个学生的总分由高到低排出名次表;
6.    按每个学生的总分由低到高排出名次表;
7.    按学号由小到大排出成绩表;
8.    按姓名的字典顺序排出成绩表;
9.    按学号查询学生排名及其考试成绩;
10.    按姓名查询学生排名及其考试成绩;需要考虑学生重名的情况。
11.    按优秀(100-90)、良好(89-80)、中等(79-70)、及格(69-60)、不及格(59-0)5个类别,对每门课程分别统计每个类别的人数以及所占的百分比;并将计算结果输出到文件,文件名可由键盘输入。
12.    将每个学生的学号、姓名、各科考试成绩、总分和平均分输出到显示器;
13.    将每个学生的个人信息和成绩写入文件,可由键盘输入文件名;
   要求程序运行后先显示如下菜单,并提示用户输入选项(菜单式循环显示,直到选择0 整个程序退出):



代码:



/*student achievement management system*/
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#include<windows.h>
#define L 32
#define N 6
#define M 30
#define LEN sizeof(struct student)
struct student
{
    char name [L];                          ///姓名
    int num;                                ///学号
    float ach[N];                           ///成绩数组
    float total;                            ///总分
    struct student *next;
};
struct student stu[M];
int count=0,n,m,j,i,k,l;
char filename[L]={0};                       ///声明变量 存储文件名
int f1(int m,int n,char filename[L]);
int f2(int m,int n,char filename[L]);
int f3(int m,int n,char filename[L]);
int f4(int m,int n,char filename[L]);
int f5(int m,int n,char filename[L]);
int f6(int m,int n,char filename[L]);
int f7(int m,int n,char filename[L]);
int f8(int m,int n,char filename[L]);
int f9(int m,int n,char filename[L]);
int f10(int m,int n,char filename[L]);
int f11(int m,int n,char filename[L]);
int f12(int m,int n,char filename[L]);
int f13(int m,int n,char filename[L]);
int main()
{
    int cishu=5;
 r0:    system("CLS");
    system("color  0C");
    char mima[L];
    printf("-------------------------------------------------------------------------------\n");
    printf("|                          欢迎使用学生信息管理系统                           |");
    printf("-------------------------------------------------------------------------------\n");
    printf("\n\n\n\n++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n");
    printf("+                                                               +\n");
    printf(">>>>>>>>>>>>>>>>>>>>>请提供管理员权限,输入系统启动密码<<<<<<<<<<<<<<<<<<<<<<<\n");
    printf("+                                                                            +\n");
    printf("+----------------------------------------------------------------------------+\n");
    printf("\n>>>>>>     码:   ");
    scanf("%s",&mima);
    cishu --;
    for(;strcmp(mima,"LLL1996")!=0;)
    {
        if(cishu==0)
        {
            printf("对不起,程序即将关闭,谢谢使用");
            getchar();
            getchar();
            exit (1);
        }
        else
        {
            printf("对不起,密码错误,请重新输入(你还有%d次输入机会)",cishu);
            getchar();
            getchar();
            goto r0;
        }
    }
    getchar();
    system("CLS");
    system("color  BC");
    printf("-------------------------------------------------------------------------------\n");
    printf("|                        WELCOME  TO  USE  THE  SYSTEM                         |");
    printf("-------------------------------------------------------------------------------\n");
    printf(" 建议:1. 使用本系统时需要首先输入班级总人数、总科目数、录入信息文件   \n");
    printf("       2. 如果您已经有输入文件,建议请先选择选项1,用于检查文件信息总数  \n");
    printf("          与录入人数、科目数是否一致,避免计算出错         \n");
    printf("       3. 如果您是初次使用本系统请先选择选项2用于创建学生信息文件,录入 \n");
    printf("          信息时填写数据较多,并耐心仔细地录入学生信息 \n                         O(∩_∩)O谢谢合作!!\n");
    printf("-------------------------------------------------------------------------------\n\n");
    printf("\n<<<< 请输入班级的总人数:     ");
    scanf("%d",&m);
    printf("\n<<<< 请输入课程总数:     ");
    scanf("%d",&n);
    printf("\n<<<< 请输入要读取或录入信息的文件的名字:     ");                   ///提示输入文件名
    getchar();
    gets(filename);                                                 ///接收输入
    for(j;;j++)
    {
        char  xuanze[3]={0};
        printf("\n\n>>>>>>>>如果想进行清屏操作请输入yes,如果想跳过清屏直接继续请按任意键!<<<<<<<<\n");
        getchar();
        gets(xuanze);
        if(strcmp(xuanze,"yes")==0)    system("CLS");
        printf("\n * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *  * * * *");
        printf("\n *                      欢迎进入学生成绩信息管理系统                          *");
        printf("\n *  一、读取文件                           >>请按1                            *");
        printf("\n *  二、录入学生成绩信息                   >>请按2                            *");
        printf("\n *  三、课程总成绩与平均分数据统计         >>请按3                            *");
        printf("\n *  四、学生个人总成绩与平均分统计         >>请按4                            *");
        printf("\n *  五、学生成绩降序排名                   >>请按5                            *");
        printf("\n *  六、学生成绩升序排名                   >>请按6                            *");
        printf("\n *  七、学生成绩按学号大小排序             >>请按7                            *");
        printf("\n *  八、姓名字典顺序排出成绩表             >>请按8                            *");
        printf("\n *  九、按学号查询学生排名及其考试成绩     >>请按9                            *");
        printf("\n *  十、按姓名查询学生排名及其考试成绩     >>请按10                           *");
        printf("\n * 十一、学生成绩各等级数据统计            >>请按11     Designd by:刘佳维     *");
        printf("\n * 十二、学生信息输出到屏幕                >>请按12                刘成亮     *");
        printf("\n * 十三、学生信息导出到文件                >>请按13                李乐       *");
        printf("\n *  零 、退出系统                          >>请按0                            *");
        printf("\n * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *  * * * * * * * * * \n");
        printf("\n请从菜单中选择一项进行操作>>>>>>>>>>\n");
        scanf("%d",&i);
        if(i==0)
            break;
        else
            switch(i)
            {
                case 1: f1(m,n,filename); break;
                case 2: f2(m,n,filename); break;
                case 3: f3(m,n,filename); break;
                case 4: f4(m,n,filename); break;
                case 5: f5(m,n,filename); break;
                case 6: f6(m,n,filename); break;
                case 7: f7(m,n,filename); break;
                case 8: f8(m,n,filename); break;
                case 9: f9(m,n,filename); break;
                case 10: f10(m,n,filename); break;
                case 11: f11(m,n,filename); break;
                case 12: f12(m,n,filename); break;
                case 13: f13(m,n,filename); break;
                default: break;
            }
        }
    printf("\n\n=====谢谢使用本系统,祝您生活愉快!=====\n\n");               ///退出界面
    return 0;
}
int f1(int m,int n,char filename[L])
{
    struct student card;
    FILE *file;
    if((file =fopen(filename,"rb"))!=NULL)                      ///打开 并判断
    {
        printf("=====文件打开成功!=====\n\n");                                ///成功则提示成功
        count=0;
        while((fread(&card,sizeof(student),1,file))!=(int)NULL)
        {
            stu[i].num=card.num;
            strcpy(stu[i].name,card.name);
            for(j=0;j<n;j++)
                stu[i].ach[j]=card.ach[j];
            stu[i].total=card.total;
            count++;
        }
        if(count<m)
            printf("=====已经录入学生信息的有%d人,还需录入%d人的信息=====\n",count,m-count);
        else if(count==m)
            printf("=====已经录入学生信息的有%d人,已经将所有成绩信息录入完毕=====\n",count);
            else
            {
                printf("=====录入学生信息大于输入的学生总数,系统将自行关闭,请检查信息后再次进入!=====");
                getchar();
                exit(1);
            }
        fclose(file);
        return count;
    }
    else
    printf("=====文件打开失败!=====\n");                                  ///打开失败则提示打开失败
    return 0;
};
int    f2(int m,int n,char filename[L])
{
   struct student card;
    FILE *file;
    if((file =fopen(filename,"rb"))!=NULL)                      ///打开 并判断
    {
        count=0;
        while((fread(&card,LEN,1,file))!=(int)NULL)
        {
            stu[i].num=card.num;
            strcpy(stu[i].name,card.name);
            for(j=0;j<n;j++)
                stu[i].ach[j]=card.ach[j];
            stu[i].total=card.total;
            count++;
        }
        if(count<m)
        {
            printf("=====已经录入学生信息的有%d人,还需录入%d人的信息=====\n",count,m-count);
            printf("<<<< 注:录入信息时,如果想中途停止输入,以后再进行补录,请将学号输为-1,谢谢!\n");
        }
        else
            printf("=====已经录入学生信息的有%d人,已经将所有成绩信息录入完毕=====\n",count);
    }
    fclose(file);
    if((file=fopen(filename,"ab"))!=NULL)
    {
        for(count;count<m;count ++)
        {
            printf("<<<< 请输入该学生的学号:\n");
            scanf("%d",&stu[count].num);
            if(stu[count].num==-1)
                goto r2;
            for(j=0;j<count;j++)
            {
                if(stu[j].num==stu[count].num)
                {
                    printf("=====学号输入重复,输入错误,请检查后再进行录入=====\n");
                    count --;
                    goto r2;
                }
            }
            stu[count].total=0;
            printf("<<<< 请输入该学生的姓名:\n");
            getchar();
            gets(stu[count].name);
            for(j=1;j<=n;j++)
            {
                printf("<<<< 请输入该学生第%d门功课的成绩:",j);
                scanf("%f",&stu[count].ach[j-1]);
                stu[count].total=stu[count].total+stu[count].ach[j-1];
            }
            fwrite(&stu[count],LEN,1,file);
        }
    }
    printf("\n=====学生信息已成功录入二进制文件 %s 中,谢谢=====\n",filename);
    fclose (file);
r2:   return 0;
};
int f3(int m,int n,char filename[L])
{
    struct student card;
    FILE *fp1;
    float zf[N]={0};
    fp1=fopen(filename,"rb");
    if(fp1==NULL)
    {
        printf("\n=====文件%s打开失败=====\n",filename);
        goto  r3;
    }
    while((fread(&card,LEN,1,fp1))!=(int)NULL)
    {
        for(i=0;i<n;i++)
        {
            zf[i]=zf[i]+card.ach[i];
        }
    }
    printf("=====课程总成绩与平均分为=====\n");
    for(i=0;i<n;i++)
    {
        printf("<<<<  第%d门课程的总成绩为%.3f    平均分为%.3f\n",i+1,zf[i],zf[i]/m);
    }
    fclose (fp1);
r3:  return 0;
};
int f4(int m,int n,char filename[L])
{
    struct student card;
    FILE *fp1;
    float zf[M]={0};
    char nam[M][L]={0};
    fp1=fopen(filename,"rb");
    if(fp1==NULL)
    {
        printf("\n=====文件%s打开失败=====\n",filename);
        goto  r4;
    }
    printf("=====学生个人总成绩与平均分为=====\n");
    for(i=0;(fread(&card,LEN,1,fp1))!=(int)NULL;i++)
    {
        strcpy(nam[i],card.name);
        zf[i]=card.total;
        printf("<<<< %s的课程的总成绩为%.3f    平均分为%.3f\n",nam[i],zf[i],zf[i]/n);
    }
    fclose (fp1);
r4:    return 0;
}
int f5(int m,int n,char filename[L])
{
    struct student card;
    FILE *fp1;
    fp1=fopen(filename,"rb");
    if(fp1==NULL)
    {
        printf("\n=====文件%s打开失败=====\n",filename);
        goto  r5;
    }
    i=0;
    while((fread(&card,sizeof(student),1,fp1))!=(int)NULL)
    {
            stu[i].num=card.num;
            strcpy(stu[i].name,card.name);
            for(j=0;j<n;j++)
                stu[i].ach[j]=card.ach[j];
            stu[i].total=card.total;
            i++;
    }
    for(k=0;k<=i;k++)
    {
        for(j=k+1;j<i;j++)
            if(stu[k].total<stu[j].total)
            {
                card=stu[k];
                stu[k]=stu[j];
                stu[j]=card;
            }
    }
    printf("=====成绩正序排名为=====\n");
    for(j=0;j<i;j++)
    {
         printf("<<<< 名次;%d     学号:%d      姓名:%s     总分:%.3f\n",j+1,stu[j].num,stu[j].name,stu[j].total);
    }
    fclose (fp1);
r5:    return 0;
};
int f6(int m,int n,char filename[L])
{
    struct student card;
    FILE *fp1;
    fp1=fopen(filename,"rb");
    if(fp1==NULL)
    {
        printf("\n文件%s打开失败\n",filename);
        goto  r6;
    }
    i=0;
    while((fread(&card,sizeof(student),1,fp1))!=(int)NULL)
    {
            stu[i].num=card.num;
            strcpy(stu[i].name,card.name);
            for(j=0;j<n;j++)
                stu[i].ach[j]=card.ach[j];
            stu[i].total=card.total;
            i++;
    }
    for(k=0;k<=i;k++)
    {
        for(j=k+1;j<i;j++)
            if(stu[j].total<stu[k].total)
            {
                card=stu[k];
                stu[k]=stu[j];
                stu[j]=card;
            }
    }
    printf("=====成绩倒序排名为=====\n");
    for(j=0;j<i;j++)
    {
         printf("<<<< 名次;%d     学号:%d      姓名:%s     总分:%.3f\n",m-j,stu[j].num,stu[j].name,stu[j].total);
    }
    fclose (fp1);
r6:    return 0;
};
int f7(int m,int n,char filename[L])
{
    struct student card;
    FILE *fp1;
    fp1=fopen(filename,"rb");
    if(fp1==NULL)
    {
        printf("\n=====文件%s打开失败=====\n",filename);
        goto  r7;
    }
    i=0;
    while((fread(&card,sizeof(student),1,fp1))!=(int)NULL)
    {
            stu[i].num=card.num;
            strcpy(stu[i].name,card.name);
            for(j=0;j<n;j++)
                stu[i].ach[j]=card.ach[j];
            stu[i].total=card.total;
            i++;
    }
    for(k=0;k<=i;k++)
    {
        for(j=k+1;j<i;j++)
            if(stu[j].num<stu[k].num)
            {
                card=stu[k];
                stu[k]=stu[j];
                stu[j]=card;
            }
    }
    printf("=====成绩依靠学号顺序排名=====\n");
    for(j=0;j<i;j++)
    {
         printf("----------------------------------------------------\n");
         printf("序号;%d      学号:%d       姓名:%s\n",j+1,stu[j].num,stu[j].name);
         for(k=0;k<n;k++)
            printf("第%d科:%.3f    ",k+1,stu[j].ach[k]);
         printf("\n总分%.3f      平均分%.3f\n",stu[j].total,stu[j].total/n);
    }
    printf("----------------------------------------------------");
    fclose(fp1);
r7:   return 0;
};

int f8(int m,int n,char filename[L])
{
    struct student card;
    FILE *fp1;
    fp1=fopen(filename,"rb");
    if(fp1==NULL)
    {
        printf("\n=====文件%s打开失败=====\n",filename);
        goto  r8;
    }
    i=0;
    while((fread(&card,sizeof(student),1,fp1))!=(int)NULL)
    {
            stu[i].num=card.num;
            strcpy(stu[i].name,card.name);
            for(j=0;j<n;j++)
                stu[i].ach[j]=card.ach[j];
            stu[i].total=card.total;
            i++;
    }                                                          ///将信息读入结构体
    for(i=0;i<m-1;i++)
        for(j=i+1;j<m;j++)
            if(strcmp(stu[i].name,stu[j].name)>0)
            {
                  card=stu[i];
                  stu[i]=stu[j];
                  stu[j]=card;
            }
            printf("=====按姓名的字典顺序排出成绩表=====");
             for(k=0;k<m;k++)
            {

                printf("----------------------------------------------------\n");
                printf("序号;%d      学号:%d       姓名:%s\n",k+1,stu[k].num,stu[k].name);
                for(i=0;i<n;i++)
                    printf("第%d科:%.3f    ",i+1,stu[k].ach[i]);
                printf("\n总分%.3f      平均分%.3f\n",stu[k].total,stu[k].total/n);
            }
    printf("----------------------------------------------------");
    fclose(fp1);
r8: return 0;
};
int f9(int m,int n,char filename[L])
{
    struct student *head,*p1,*p2;
    int ChooseNum;
    printf("=====请输入要查询信息的学生的学号:=====\n");
    scanf("%d",&ChooseNum);
    struct student card;
    FILE *fp1;
    fp1=fopen(filename,"rb");
    if(fp1==NULL)
    {
        printf("\n=====文件%s打开失败=====\n",filename);
        goto  r9;
    }
    i=0;
    while((fread(&card,LEN,1,fp1))!=(int)NULL)
    {
            stu[i].num=card.num;
            strcpy(stu[i].name,card.name);
            for(j=0;j<n;j++)
                stu[i].ach[j]=card.ach[j];
            stu[i].total=card.total;
            i++;
    }                                                                ///读入到结构体数组
    for(k=0;k<=i;k++)
    {
        for(j=k+1;j<i;j++)
            if(stu[k].total<stu[j].total)
            {
                card=stu[k];
                stu[k]=stu[j];
                stu[j]=card;
            }
    }                                                                ///排名
    head=&stu[0];
    p1=&stu[1];
    p2=NULL;
    head->next=p1;
    p1->next=p2;                                                    ///建立链表
    if(head->num==ChooseNum)
    {
         {
            printf("名次;%d      学号:%d       姓名:%s\n",i+1,head->num,head->name);
            for(k=0;k<n;k++)
                printf("第%d科:%.3f    ",k+1,head->ach[k]);
            printf("\n总分%.3f      平均分%.3f\n",head->total,head->total/n);
            goto r9;
         }
    }
    else
        for(i=1;1<m;i++)
        {
            p1=&stu[i];
            p1->next=p2;
            if(p1->num==ChooseNum)
            {
                printf("名次;%d      学号:%d       姓名:%s\n",i+1,p1->num,p1->name);
                for(k=0;k<n;k++)
                    printf("第%d科:%.3f    ",k+1,p1->ach[k]);
                printf("\n总分%.3f      平均分%.3f\n",p1->total,p1->total/n);
                goto r9;
            }
        }
r9:  return 0;
}
int f10(int m,int n,char filename[L])
{
    char ChooseName[L];
    printf("<<<< 请输入要查询的学生的姓名:\n");
    getchar();
    gets(ChooseName);
    struct student card;
    FILE *fp1;
    fp1=fopen(filename,"rb");
    if(fp1==NULL)
    {
        printf("\n=====文件%s打开失败=====\n",filename);
        goto  r10;
    }
    i=0;
    while((fread(&card,sizeof(student),1,fp1))!=(int)NULL)
    {
            stu[i].num=card.num;
            strcpy(stu[i].name,card.name);
            for(j=0;j<n;j++)
                stu[i].ach[j]=card.ach[j];
            stu[i].total=card.total;
            i++;
    }
    for(k=0;k<=i;k++)
    {
        for(j=k+1;j<i;j++)
            if(stu[k].total<stu[j].total)
            {
                card=stu[k];
                stu[k]=stu[j];
                stu[j]=card;
            }
    }
    printf("=====按姓名查询学生排名及其考试成绩=====\n");
     for(j=0;j<i;j++)
    {
        if(strcmp(stu[j].name,ChooseName)==0)
        {
            printf("----------------------------------------------------\n");
            printf("名次;%d      学号:%d       姓名:%s\n",j+1,stu[j].num,stu[j].name);
            for(k=0;k<n;k++)
                printf("第%d科:%.3f    ",k+1,stu[j].ach[k]);
            printf("\n总分%.3f      平均分%.3f\n",stu[j].total,stu[j].total/n);
        }
    }
    printf("----------------------------------------------------");
    fclose(fp1);
 r10:  return 0;
};
int f11(int m,int n,char filename[L])
{
    char  output[L];
    float a=0,b=0,c=0,d=0,e=0;
    struct student card;
    FILE *fp1,*fp2;
    fp1=fopen(filename,"rb");
    printf("\n<<<< 请输入要输出到文件的名字:\n");                   ///提示输入文件名
    getchar();
    gets(output);                                                 ///接收输入
    fp2=fopen(output,"w");
    if(fp1==NULL)
    {
        printf("\n=====文件%s打开失败=====\n",filename);
        goto  r11;
    }
    if(fp2==NULL)
    {
        printf("\n=====文件%s打开失败=====\n",output);
        goto  r11;
    }
    i=0;
    while((fread(&card,sizeof(student),1,fp1))!=(int)NULL)
    {
            stu[i].num=card.num;
            strcpy(stu[i].name,card.name);
            for(j=0;j<n;j++)
                stu[i].ach[j]=card.ach[j];
            stu[i].total=card.total;
            i++;
    }
    fprintf(fp2,"=======================================各科目成绩分析=============================================\n总参考人数:%d\n考试科目数:%d\n",i,n);
    fprintf(fp2,"   科目     优秀(比例)      良好(比例)     中等(比例)     及格(比例)     不及格(比例)\n");
    fprintf(fp2,"             <90-100>           <80-89>          <70-79>          <60-69>           <0-59>\n");
    fprintf(fp2,"==================================================================================================\n");
    for(k=0;k<n;k++)       ///课程
    {
        a=0,b=0,c=0,d=0,e=0;
        for(j=0;j<m;j++)    ///学生
        {
            if((stu[j].ach[k]<=100)&&(stu[j].ach[k]>=90))
                a++;
            else if((stu[j].ach[k]<=89)&&(stu[j].ach[k]>=80))
                    b++;
                else if((stu[j].ach[k]<=79)&&(stu[j].ach[k]>70))
                        c++;
                    else if((stu[j].ach[k]<=69)&&(stu[j].ach[k]>=60))
                            d++;
                        else if((stu[j].ach[k]<=59)&&(stu[j].ach[k]>=0))
                                e++;
        }
        fprintf(fp2,"   第%d科     %.0f人(%.3f%%)    %.0f人(%.3f%%)    %.0f人(%.3f%%)    %.0f人(%.3f%%)    %.0f人(%.3f%%)\n",k+1,a,a/m*100,b,b/m*100,c,c/m*100,d,d/m*100,e,e/m*100);
    }
    printf("=====已经将所有信息写入到文件%s中,请注意接收!=====\n",output);
r11:  return 0;
};
int f12(int m,int n,char filename[L])
{
    struct student card;
    FILE *fp1;
    fp1=fopen(filename,"rb");
    if(fp1==NULL)
    {
        printf("\n=====文件%s打开失败=====\n",filename);
        goto  r12;
    }
    i=0;
    while((fread(&card,sizeof(student),1,fp1))!=(int)NULL)
    {
            stu[i].num=card.num;
            strcpy(stu[i].name,card.name);
            for(j=0;j<n;j++)
                stu[i].ach[j]=card.ach[j];
            stu[i].total=card.total;
            i++;
    }
    for(k=0;k<=i;k++)
    {
        for(j=k+1;j<i;j++)
            if(stu[k].total<stu[j].total)
            {
                card=stu[k];
                stu[k]=stu[j];
                stu[j]=card;
            }
    }
    printf("=====学生所有信息屏幕输出=====\n");
     for(j=0;j<i;j++)
    {
         printf("----------------------------------------------------\n");
         printf("名次;%d      学号:%d       姓名:%s\n",j+1,stu[j].num,stu[j].name);
         for(k=0;k<n;k++)
            printf("第%d科:%.3f    ",k+1,stu[j].ach[k]);
         printf("\n总分%.3f      平均分%.3f\n",stu[j].total,stu[j].total/n);
    }
    printf("----------------------------------------------------");
    fclose(fp1);
 r12:  return 0;
};
int f13(int m,int n,char filename[L])
{
    char  output[L]={0};
    struct student card;
    FILE *fp1,*fp2;
    fp1=fopen(filename,"rb");
    printf("\n<<<< 请输入要输出到文件的名字:\n");                   ///提示输入文件名
    getchar();
    gets(output);                                                 ///接收输入
    fp2=fopen(output,"w");
    if(fp1==NULL)
    {
        printf("\n=====文件%s打开失败=====\n",filename);
        goto  r13;
    }
    if(fp2==NULL)
    {
        printf("\n=====文件%s打开失败=====\n",output);
        goto  r13;
    }
    i=0;
    while((fread(&card,LEN,1,fp1))!=(int)NULL)
    {
            stu[i].num=card.num;
            strcpy(stu[i].name,card.name);
            for(j=0;j<n;j++)
                stu[i].ach[j]=card.ach[j];
            stu[i].total=card.total;
            i++;
    }
    for(k=0;k<=i;k++)
    {
        for(j=k+1;j<i;j++)
            if(stu[k].total<stu[j].total)
            {
                card=stu[k];
                stu[k]=stu[j];
                stu[j]=card;
            }
    }
    printf("=====已经将所有信息写入到文件%s中,请注意接收!=====\n",output);
     for(j=0;j<i;j++)
    {
         fprintf(fp2,"----------------------------------------------------\n");
         fprintf(fp2,"名次;%d      学号:%d       姓名:%s\n",j+1,stu[j].num,stu[j].name);
         for(k=0;k<n;k++)
            fprintf(fp2,"第%d科:%.3f    ",k+1,stu[j].ach[k]);
         fprintf(fp2,"\n总分%.3f      平均分%.3f\n",stu[j].total,stu[j].total/n);
    }
    fprintf(fp2,"----------------------------------------------------");
    fclose(fp1);
    fclose(fp2);
 r13:  return 0;
};



欢迎围观,引用请注明出处
有不当之处,欢迎斧正
搜索更多相关主题的帖子: 个人信息 管理系统 考试成绩 中文 
2015-03-30 21:25
阿维
Rank: 2
来 自:china
等 级:论坛游民
帖 子:30
专家分:43
注 册:2014-11-10
收藏
得分:0 
回复 2楼 longwu9t
是在codeblocks下写的,个人在codeblocks与vc6.0下运行完美,不过初始进入有密码,LLL1996,O(∩_∩)O谢谢
2015-03-30 21:38
阿维
Rank: 2
来 自:china
等 级:论坛游民
帖 子:30
专家分:43
注 册:2014-11-10
收藏
得分:0 
回复 2楼 longwu9t
加问一下在什么编译器下调试不能通过,我处理一下
2015-03-30 21:41
阿维
Rank: 2
来 自:china
等 级:论坛游民
帖 子:30
专家分:43
注 册:2014-11-10
收藏
得分:0 
回复 6楼 longwu9t
你所说的这几个编译环境我也恰恰没有
也就没办法了。。
但还是感谢!
2015-03-30 21:48
阿维
Rank: 2
来 自:china
等 级:论坛游民
帖 子:30
专家分:43
注 册:2014-11-10
收藏
得分:0 
回复 8楼 wmf2014
谢谢指正!
2015-03-31 14:24
快速回复:自己写的一个关于学生信息管理系统的小程序,欢迎围观
数据加载中...
 
   



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

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