| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1130 人关注过本帖
标题:最终修订的成绩管理系统
只看楼主 加入收藏
AirF3101
Rank: 1
等 级:新手上路
帖 子:29
专家分:0
注 册:2017-3-13
结帖率:66.67%
收藏
已结贴  问题点数:10 回复次数:3 
最终修订的成绩管理系统
现在发现的问题是统计有错,文件的存储和读写有点问题,跑程序有烫,但是文件里又是对的
希望大神们帮忙改改,谢谢!有点急哈哈哈哈


程序代码:
#include"stdio.h"
#include"string.h"
#define N 2

struct infor
{
    int ID;
    char name[10];
    char position[10];
    int age;
    int grade;
    char level[10];
};


void scanfs(struct infor people1[N], int flag)
{
    int m, n, i;
    printf("\n\t请输入员工信息\n工号\t姓名\t岗位\t年龄\t成绩\n");
    for (m = 0; m < N; m++)
    {
        scanf("%d%s%*c%s%*c%d%d", &people1[m].ID, people1[m].name, people1[m].position, &people1[m].age, &people1[m].grade);
    }
    for (i = 0; i < N; i++)
    {
        if (people1[i].grade >= 90)
            strcpy(people1[i].level, "优秀");
        if ((people1[i].grade > 79) && (people1[i].grade<90))
            strcpy(people1[i].level, "良好");
        if ((people1[i].grade > 69) && (people1[i].grade<80))
            strcpy(people1[i].level, "中等");
        if ((people1[i].grade > 59) && (people1[i].grade<70))
            strcpy(people1[i].level, "及格");
        if (people1[i].grade < 60)
            strcpy(people1[i].level, "不及格");
    }
    for (n = 0; n < 41; n++)
    {
        printf("*");
        if (n == 40)
        {
            printf("\n");
        }
    }
}
void printfs(struct infor people2[N], int flag)
{
    int n, i;
    if (flag == 0)
    {
        printf("请先输入员工信息(先输入1再输入员工信息)\n");
        for (i = 0; i < 41; i++)

        {
            printf("*");
            if (i == 40)
            {
                printf("\n");
            }
        }
        return;
    }
    printf("工号\t姓名\t岗位\t年龄\t成绩\t等级\n");
    for (i = 0; i < N; i++)
    {
        if (people2[i].grade >= 90)
            strcpy(people2[i].level, "优秀");
        if ((people2[i].grade > 79) && (people2[i].grade<90))
            strcpy(people2[i].level, "良好");
        if ((people2[i].grade > 69) && (people2[i].grade<80))
            strcpy(people2[i].level, "中等");
        if ((people2[i].grade > 59) && (people2[i].grade<70))
            strcpy(people2[i].level, "及格");
        if (people2[i].grade < 60)
            strcpy(people2[i].level, "不及格");
    }
    for (n = 0; n < N; n++)
    {
        printf("%d\t%s\t%s\t%d\t%d\t%s\n", people2[n].ID, people2[n].name, people2[n].position, people2[n].age, people2[n].grade, people2[n].level);
    }
    for (i = 0; i < 41; i++)

    {
        printf("*");
        if (i == 40)
        {
            printf("\n");
        }
    }
}

void tongji(struct infor people[N], int flag)
{
    int n, i, 优秀, 良好, 中等 , 及格, 不及格;
    优秀=良好=中等=及格=不及格=0;
    if (flag == 0)
    {
        printf("请先输入员工信息(先输入1再输入员工信息)\n");
        for (n = 0;n<41;n++)
        {
            printf("*");
            if (n == 40)
                printf("\n");
        }
        return;
    }
    for (i = 0; i < N; i++)
    {
        if (people[i].grade >= 90)
            优秀++;
        if (people[i].grade > 79 && people[i].grade < 90)
            良好++;
        if (people[i].grade > 69 && people[i].grade < 80)
            中等++;
        if (people[i].grade > 59 && people[i].grade < 70)
            及格++;
        if (people[i].grade < 60)
            不及格++;
    }
    printf("优秀的人有%d个\n良好的人有%d个\n中等的人有%d个\n及格的人有%d个\n不及格的人有%d个\n", '优秀', '良好','中等','及格','');
    for (n = 0; n < 41; n++)
    {
        printf("*");
        if (n == 40)
        {
            printf("\n");
        }
    }
}

void chakan(struct infor people[N], int flag)
{
    int n, i, max, min;
    if (flag == 0)
    {
        printf("请先输入员工信息(先输入1再输入员工信息)\n");
        for (n = 0; n < 41; n++)
        {
            printf("*");
            if (n == 40)
            {
                printf("\n");
            }
        }
        return;
    }
    max = min = 0;
    for (i = 0; i < N; i++)
    {
        for (i = 0; i < N; i++)
        {
            if (people[i].grade >= 90)
                strcpy(people[i].level, "优秀");
            if ((people[i].grade > 79) && (people[i].grade<90))
                strcpy(people[i].level, "良好");
            if ((people[i].grade > 69) && (people[i].grade<80))
                strcpy(people[i].level, "中等");
            if ((people[i].grade > 59) && (people[i].grade<70))
                strcpy(people[i].level, "及格");
            if (people[i].grade < 60)
                strcpy(people[i].level, "不及格");
            if (people[i].grade >= people[max].grade)
                max = i;
            if (people[i].grade <= people[min].grade)
                min = i;
        }
        printf("\t\t工号\t姓名\t岗位\t年龄\t成绩\t等级\n");
        printf("最高成绩的员工\t%d\t%s\t%s\t%d\t%d\t%s\n", people[max].ID, people[max].name, people[max].position, people[max].age, people[max].grade, people[max].level);
        printf("最低成绩的员工\t%d\t%s\t%s\t%d\t%d\t%s\n", people[min].ID, people[min].name, people[min].position, people[min].age, people[min].grade, people[min].level);
    }
    for (n = 0; n < 41; n++)
    {
        printf("*");
        if (n == 40)
        {
            printf("\n");
        }
    }
}

void gengzheng(struct infor people[N], int flag)
{
    int n, a, i, f, x, m;
    if (flag == 0)
    {
        printf("请输入员工信息\n");
        return;
    }
    for (i = 0;; i++)
    {
        for (n = 0; n < 41; n++)
        {
            printf("*");
            if (n == 40)
            {
                printf("\n");
            }
        }

        if (flag == 0)
        {
            printf("请先输入员工信息(先输入1再输入员工信息)\n");
            for (n = 0; n < 41; n++)
            {
                printf("*");
                if (n == 40)
                {
                    printf("\n");
                }
            }
            return;
        }
        for (i = 0; i < N; i++)
        {
            if (people[i].grade >= 90)
                strcpy(people[i].level, "优秀");
            if ((people[i].grade > 79) && (people[i].grade < 90))
                strcpy(people[i].level, "良好");
            if ((people[i].grade > 69) && (people[i].grade < 80))
                strcpy(people[i].level, "中等");
            if ((people[i].grade > 59) && (people[i].grade < 70))
                strcpy(people[i].level, "及格");
            if (people[i].grade < 60)
                strcpy(people[i].level, "不及格");
        }
        printf("工号\t姓名\t岗位\t年龄\t成绩\t等级\n");
        for (i = 0; i < N; i++)
        {
            printf("%d\t%s\t%s\t%d\t%d\t%s\n", people[i].ID, people[i].name, people[i].position, people[i].age, people[i].grade, people[i].level);
        }

        printf("请输入更改信息员工的工号\n");
        scanf("%d", &x);
        for (n = 0; n < 41; n++)
        {
            printf("*");
            if (n == 40)
            {
                printf("\n");
            }
        }
        for (n = 0, m = 0; n<N; n++, m++)
        {
            if (x == people[n].ID)
            {
                f = n;
                for (i = 0;; i++)
                {
                    printf("1.改正工号\n2.改正名字\n3.改正岗位\n4.改正年龄\n5.改正成绩\n0.改正完毕\n");
                    scanf("%d", &a);
                    switch (a)
                    {
                    case 1:printf("请输入改正的工号\n"), scanf("%d", &people[f].ID); break;
                    case 2:printf("请输入改正的名字\n"), scanf("%s", people[f].name); break;
                    case 3:printf("请输入改正的岗位\n"), scanf("%s", people[f].position); break;
                    case 4:printf("请输入改正的年龄\n"), scanf("%d", &people[f].age); break;
                    case 5:printf("请输入改正的成绩\n"), scanf("%d", &people[f].grade); break;
                    case 0:for (i = 0; i < 41; i++)
                    {
                        printf("*");
                        if (i == 40)
                        {
                            printf("\n");
                        }
                    }return; break;
                    }
                    printf("工号\t姓名\t岗位\t年龄\t成绩\t等级\n");
                    for (i = 0; i < N; i++)
                    {
                        if (people[i].grade >= 90)
                            strcpy(people[i].level, "优秀");
                        if ((people[i].grade > 79) && (people[i].grade < 90))
                            strcpy(people[i].level, "良好");
                        if ((people[i].grade > 69) && (people[i].grade < 80))
                            strcpy(people[i].level, "中等");
                        if ((people[i].grade > 59) && (people[i].grade < 70))
                            strcpy(people[i].level, "及格");
                        if (people[i].grade < 60)
                            strcpy(people[i].level, "不及格");
                    }
                    for (i = 0;i < N; i++)
                    {
                        printf("%d\t%s\t%s\t%d\t%d\t%s\n", people[i].ID, people[i].name, people[i].position, people[i].age, people[i].grade, people[i].level);
                    }
                    for (i = 0; i < 41; i++)
                    {
                        printf("*");
                        if (i == 40)
                        {
                            printf("\n");
                        }
                    }
                }
            }
        }
        if (m == n)
            printf("输入的工号错误,无此员工\n");
    }
}
void paixu(struct infor people[N], int flag)
{
    if (flag == 0)
    {
        printf("请先输入员工信息\n");
        for (int n = 0; n < 41; n++)
        {
            for (int n = 0; n<41; n++)
            {
                printf("*");
                if (n == 40)
                    printf("\n");
            }
            return;
        }
    }
    int mark[N], i, mid, a, j;
    for (int n = 0; n<41; n++)
    {
        printf("*");
        if (n == 40)
            printf("\n");
    }
    for (int m = 0;; m++)
    {
        printf("1.按照学号排序\n2.按照成绩排序\n3.按照年龄排序\n0.退出排序\n");
        for (i = 0; i < N; i++)
        {
            mark[i] = i;
        }
        scanf("%d", &a);
        switch (a)
        {
        case 1:for (j = 1; j < N - 1; j++)
        {
            for (i = 0; i < N - j; i++)
            {
                if (people[mark[i]].ID > people[mark[i + 1]].ID)
                {
                    mid = mark[i] + mark[i + 1];
                    mark[i] = mid - mark[i];
                    mark[i + 1] = mid - mark[i];
                }
            }
        }; break;
        case 2:for (j = 1; j < N - 1; j++)
        {
            for (i = 0; i < N - j; i++)
            {
                if (people[mark[i]].grade > people[mark[i + 1]].grade)
                {
                    mid = mark[i] + mark[i + 1];
                    mark[i] = mid - mark[i];
                    mark[i + 1] = mid - mark[i];
                }
            }
        }; break;
        case 3:for (j = 1; j < N - 1; j++)
        {
            for (i = 0; i < N - j; i++)
            {
                if (people[mark[i]].age > people[mark[i + 1]].age)
                {
                    mid = mark[i] + mark[i + 1];
                    mark[i] = mid - mark[i];
                    mark[i + 1] = mid - mark[i];
                }
            }
        }; break;
        case 0:return; break;
        }
        for (i = 0; i < N; i++)
        {
            if (people[i].grade >= 90)
                strcpy(people[i].level, "优秀");
            if ((people[i].grade > 79) && (people[i].grade < 90))
                strcpy(people[i].level, "良好");
            if ((people[i].grade > 69) && (people[i].grade < 80))
                strcpy(people[i].level, "中等");
            if ((people[i].grade > 59) && (people[i].grade < 70))
                strcpy(people[i].level, "及格");
            if (people[i].grade < 60)
                strcpy(people[i].level, "不及格");
        }
        printf("工号\t姓名\t岗位\t年龄\t成绩\t等级\n");
        for (i = 0; i < N; i++)
        {
            printf("%d\t%s\t%s\t%d\t%d\t%s\n", people[mark[i]].ID, people[mark[i]].name, people[mark[i]].position, people[mark[i]].age, people[mark[i]].grade, people[mark[i]].level);
        }
        for (int n = 0; n<41; n++)
        {
            printf("*");
            if (n == 40)
                printf("\n");
        }
    }
}
void chucun(struct infor people[N], int flag)
{
    FILE*fp;
    char address[20], abc[100];
    int i;
    if (flag == 0)
    {
        printf("请先输入员工信息\n");
        for (i = 0; i < 41; i++)

        {
            printf("*");
            if (i == 40)
            {
                printf("\n");
            }
        }
    }
    printf("请输入存放路径:");
    scanf("%s", address);
    strcpy(abc, "工号\t姓名\t岗位\t年龄\t成绩\t等级\n");
    fp = fopen(address, "w");
    fprintf(fp, "%s", abc);
    for (i = 0; i < N; i++)
    {
        fprintf(fp, "%d\t%s\t%s\t%d\t%d\t%s\n", people[i].ID, people[i].name, people[i].position, people[i].age, people[i].grade, people[i].level);
    }
    fclose(fp);
    for (i = 0; i < 41; i++)

    {
        printf("*");
        if (i == 40)
        {
            printf("\n");
        }
    }
}

void duxie(struct infor people[N], int flag)
{
    FILE*fp;
    char abc[100], address[20];
    int i;
    printf("请输入读取路径:");
    scanf("%s", address);
    fp = fopen(address, "r");
    strcpy(abc, "工号\t姓名\t岗位\t年龄\t成绩\t等级\n");
    fscanf(fp, "%s", abc);
    for (i = 0; i < N; i++)
    {
        fscanf(fp, "%d\t%s\t%s\t%d\t%d\t%s\n", people[i].ID, people[i].name, people[i].position, people[i].age, people[i].grade, people[i].level);
    }
    fclose(fp);
    for (i = 0; i < 41; i++)

    {
        printf("*");
        if (i == 40)
        {
            printf("\n");
        }
    }
}

void menu()
{
        struct infor people[N];
        int n, m, flag = 0, it;
        do
        {
            puts("\t\t*********************************************");
            puts("\t\t*********************************************");
            puts("\t\t**************学生成绩系统菜单***************");
            puts("\t\t*********************************************");
            puts("\t\t********************************************************************");
            puts("\t\t*******        1--输入并显示员工信息                            ****");
            puts("\t\t*******        2--统计各等级员工各有多少人                ****");
            puts("\t\t*******        3--查询考核得分最高和最低员工信息        ****");
            puts("\t\t*******        4--查询并修改员工信息                            ****");
            puts("\t\t*******        5--按需求对员工信息进行排序                ****");
            puts("\t\t*******        6--将员工信息存储到硬盘上                    ****");
            puts("\t\t*******        7--从硬盘上读取员工信息                        ****");
            puts("\t\t*******        8--退出当前程序                                    ****");
            puts("\t\t********************************************************************");
mark:
            printf("请选择服务种类(0~8): [ ]\b\b");
            scanf("%d", &n);
            if (n<1 || n>8)
            {
                //system("cls");
                printf("选择错误! 请重新选择!\n");
                m = 1;
            }
            else
            {
                m = 0;
            }
        } 
        while (m==1);
        {
            switch (n)
            {
            case 1: scanfs(people, flag), flag = 1; 
                        printfs(people, flag); break;
            case 2: tongji(people, flag); break;
            case 3:chakan(people, flag); break;
            case 4:gengzheng(people, flag), flag = 1; break;
            case 5:paixu(people, flag); break;
            case 6:chucun(people, flag); break;
            case 7:duxie(people, flag), flag = 1; break;
            case 8:return 0; break;
            default:printf("输入错误!"); break;
            }
        }
        printf("\n是否继续运行菜单\n");
        printf("1.继续运行\n");
        printf("0.退出\n");
        scanf("%d", &it);
        switch (it)
        {
        case 1:
            goto mark;
            break;
        case 0:
            break;
        }

}




int main()
{//    struct infor people1[N];
//    int flag;
    menu();
//     scanfs( people1[N],  flag);//输入员工信息声明
//     printfs(people2[N],  flag);//显示员工信息声明
///     tongji(people[N],  flag);//统计各等级人数并输出声明
//     chakan(people[N],  flag);//查询最高最低声明
//     gengzheng(people[N],  flag);//更正员工信息
//     paixu(people[N],  flag);
//     chucun(people[N],  flag);
//     duxie(people[N],  flag);
    return 0;
}
搜索更多相关主题的帖子: 管理系统 统计 
2017-04-20 13:32
renkejun1942
Rank: 14Rank: 14Rank: 14Rank: 14
来 自:不是这样
等 级:贵宾
威 望:33
帖 子:1645
专家分:5297
注 册:2016-12-1
收藏
得分:5 
粗略看了一下,函数好长。

[此贴子已经被作者于2017-4-20 15:36编辑过]


09:30 05/21 种下琵琶种子,能种活么?等待中……
21:50 05/27 没有发芽。
20:51 05/28 没有发芽。
23:03 05/29 没有发芽。
23:30 06/09 我有预感,要发芽了。
2017-04-20 15:33
AirF3101
Rank: 1
等 级:新手上路
帖 子:29
专家分:0
注 册:2017-3-13
收藏
得分:0 
回复 2楼 renkejun1942
帮我看看呗,谢谢咯
2017-04-20 16:09
高威
Rank: 1
等 级:新手上路
帖 子:18
专家分:7
注 册:2016-6-5
收藏
得分:5 
#include"stdio.h"
#include"string.h"
#define N 2
struct infor
{
    int ID;
    char name[10];
    char position[10];
    int age;
    int grade;
    char level[10];
}people1[N];
void scanfs(struct infor people1[N])
{
    int m,i;
    printf("\n\t请输入员工信息\n工号\t姓名\t岗位\t年龄\t成绩\n");
    for (m = 0; m < N; m++)
    {
        scanf("%d %s %s %d %d", &people1[m].ID, people1[m].name, people1[m].position, &people1[m].age, &people1[m].grade);
    }
    for (i = 0; i < N; i++)
    {
        if (people1[i].grade >= 90)
            strcpy(people1[i].level, "优秀");
        if ((people1[i].grade > 79) && (people1[i].grade<90))
            strcpy(people1[i].level, "良好");
        if ((people1[i].grade > 69) && (people1[i].grade<80))
            strcpy(people1[i].level, "中等");
        if ((people1[i].grade > 59) && (people1[i].grade<70))
            strcpy(people1[i].level, "及格");
        if (people1[i].grade < 60)
            strcpy(people1[i].level, "不及格");
    }
}
void printfs(struct infor people1[N])
{
    int n;
    printf("工号\t姓名\t岗位\t年龄\t成绩\t等级\n");
    for (n = 0; n < N; n++)
    {
        printf("%d\t%s\t%s\t%d\t%d\t%s\n", people1[n].ID, people1[n].name, people1[n].position, people1[n].age, people1[n].grade, people1[n].level);
    }
}
void tongji(struct infor people1[N])
{
    int i;
    int good,fine,medium,pass,fail;
    good=fine=medium=pass=fail=0;
    for (i = 0; i < N; i++)
    {
        if (people1[i].grade >= 90)
            good++;
        if (people1[i].grade > 79 && people1[i].grade < 90)
            fine++;
        if (people1[i].grade > 69 && people1[i].grade < 80)
            medium++;
        if (people1[i].grade > 59 && people1[i].grade < 70)
            pass++;
        if (people1[i].grade < 60)
            fail++;
    }
    printf("优秀的人有%d个\n良好的人有%d个\n中等的人有%d个\n及格的人有%d个\n不及格的人有%d个\n", good, fine,medium,pass,fail);
}
void chakan(struct infor people1[N])
{
    int i, max, min;
    max=min=0;
    for (i = 0; i < N; i++)
    {
        if (people1[i].grade >= people1[max].grade)
                max = i;
        if (people1[i].grade <= people1[min].grade)
                min = i;
    }
    printf("\t\t工号\t姓名\t岗位\t年龄\t成绩\t等级\n");
    printf("最高成绩的员工\t%d\t%s\t%s\t%d\t%d\t%s\n", people1[max].ID, people1[max].name, people1[max].position, people1[max].age, people1[max].grade, people1[max].level);
    printf("最低成绩的员工\t%d\t%s\t%s\t%d\t%d\t%s\n", people1[min].ID, people1[min].name, people1[min].position, people1[min].age, people1[min].grade, people1[min].level);
}
void gengzheng(struct infor people1[N])
{
    int a,f=0,i,x,flag=1,flag1=1;
    char m,n;
    printf("修改说明:\n1.改正工号\n2.改正名字\n3.改正岗位\n4.改正年龄\n5.改正成绩\n");
    while(flag)
    {
        printf("请输入更改信息员工的工号:");
        scanf(" %d", &x);
        for(i=0;i<N;i++)
        {
            if(x==people1[i].ID)
            {
                f=1;
                while(flag1)
                {
                    printf("请输入更改的选项(例如:2):");
                    scanf("%d",&a);
                    switch (a)
                    {
                    case 1:printf("请输入改正的工号:"), scanf("%d", &people1[i].ID); break;
                    case 2:printf("请输入改正的名字:"), scanf("%s", people1[i].name); break;
                    case 3:printf("请输入改正的岗位:"), scanf("%s", people1[i].position); break;
                    case 4:printf("请输入改正的年龄:"), scanf("%d", &people1[i].age); break;
                    case 5:printf("请输入改正的成绩:"), scanf("%d", &people1[i].grade); break;
                    }
                    printf("是否继续修改该员工信息,是输入Y,否输入N?");
                    scanf(" %c",&m);
                    if(m=='Y')
                        flag1=1;
                    else
                        flag1=0;
                }
                if (people1[i].grade >= 90)
                    strcpy(people1[i].level, "优秀");
                if ((people1[i].grade > 79) && (people1[i].grade < 90))
                    strcpy(people1[i].level, "良好");
                if ((people1[i].grade > 69) && (people1[i].grade < 80))
                    strcpy(people1[i].level, "中等");
                if ((people1[i].grade > 59) && (people1[i].grade < 70))
                    strcpy(people1[i].level, "及格");
                if (people1[i].grade < 60)
                    strcpy(people1[i].level, "不及格");
                printf("修改后的员工信息:\n");
                printf("工号\t姓名\t岗位\t年龄\t成绩\t等级\n");
                printf("%d\t%s\t%s\t%d\t%d\t%s\n", people1[i].ID, people1[i].name, people1[i].position, people1[i].age, people1[i].grade, people1[i].level);
            break;
            }
        }
        if(f=0)
        {
            printf("无该员工\n");
        }
        printf("是否继续修改其他员工信息,是输入Y,否输入N?");
        scanf(" %c",&n);
        if(n=='Y')
        {
            flag=1;
            flag1=1;
            f=0;
        }
        else
        {
            flag=0;
        }
    }
}
void paixu(struct infor people1[N])
{
    int i,flag=1,a;
    char n;
    struct infor temp;
    printf("1.按照工号排序\n2.按照成绩排序\n3.按照年龄排序\n");
    while(flag)
    {
        printf("请输入排序方式(例如:1):");
        scanf("%d",&a);
        if(a==1)
        {
            for(i=0;i<N-1;i++)
            {
                if(people1[i].ID>=people1[i+1].ID)
                {
                    temp=people1[i];
                    people1[i]=people1[i+1];
                    people1[i+1]=temp;
                }
            }
        }
        if(a==2)
        {
            for(i=0;i<N-1;i++)
            {
                if(people1[i].grade>=people1[i+1].grade)
                {
                    temp=people1[i];
                    people1[i]=people1[i+1];
                    people1[i+1]=temp;
                }
            }
        }
        if(a==3)
        {
            for(i=0;i<N-1;i++)
            {
                if(people1[i].age>=people1[i+1].age)
                {
                    temp=people1[i];
                    people1[i]=people1[i+1];
                    people1[i+1]=temp;
                }
            }
        }
        printf("是否继续使用其他排序方式,是输入Y,否输入N?");
        scanf(" %c",&n);
        if(n=='Y')
            flag=1;
        else
            flag=0;
    }
}
void chucun(struct infor people1[N])
{
    FILE *fp;
    char address[50];
    int i;
    printf("请输入存放路径:");
    scanf("%s", address);
    fp = fopen(address, "w");
    for (i = 0; i < N; i++)
    {
        fwrite(&people1[i],sizeof(struct infor),1,fp);
    }
    fclose(fp);
}
void duxie(struct infor people1[N])
{
    FILE *fp;
    char address[50];
    int i;
    struct infor p[N];
    printf("请输入读取路径:");
    scanf("%s", address);
    fp = fopen(address, "r");
    printf("工号\t姓名\t岗位\t年龄\t成绩\t等级\n");
    for (i = 0; i < N; i++)
    {
        fread(&p[i],sizeof(struct infor),1,fp);
        printf("%d\t%s\t%s\t%d\t%d\t%s\n", people1[i].ID, people1[i].name, people1[i].position, people1[i].age, people1[i].grade, people1[i].level);
    }
    fclose(fp);
}
int main()
{
    int n,flag1=1,flag=1;
    char m;
    puts("*********************************************");
    puts("**************学生成绩系统菜单***************");
    puts("*********************************************");
    puts("*******     1--输入员工信息                    ****");
    puts("*******     2--显示员工信息                    ****");
    puts("*******     3--统计各等级员工各有多少人              ****");
    puts("*******     4--查询考核得分最高和最低员工信息        ****");
    puts("*******     5--查询并修改员工信息                    ****");
    puts("*******     6--按需求对员工信息进行排序              ****");
    puts("*******     7--将员工信息存储到硬盘上                ****");
    puts("*******     8--从硬盘上读取员工信息                  ****");
    while(flag)
    {
        while(flag1)
        {
            printf("请选择服务种类(0~8):");
            scanf("%d",&n);
            if (n<1 || n>8)
            {
                printf("选择错误! 请重新选择!\n");
                flag1=1;
            }
            else
            {
                flag1=0;
            }
        }
        while(!flag1)
        {
            switch (n)
            {
            case 1:scanfs(people1);break;
            case 2:printfs(people1);break;
            case 3:tongji(people1); break;
            case 4:chakan(people1); break;
            case 5:gengzheng(people1); break;
            case 6:paixu(people1); break;
            case 7:chucun(people1); break;
            case 8:duxie(people1); break;
            }
            flag1=1;
        }
        printf("\n是否继续运行菜单是输入Y,否输入N:");
        scanf(" %c",&m);
        if(m=='Y')
        {
            flag=1;
        }
        else
        {
            flag=0;
        }
    }
    return 0;
}
我改了很多地方,版主可以把程序每个功能运行一遍。我也是个新手,如有问题,请多指教。
2017-04-22 12:10
快速回复:最终修订的成绩管理系统
数据加载中...
 
   



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

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