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


程序代码:
#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
AirF3101
Rank: 1
等 级:新手上路
帖 子:29
专家分:0
注 册:2017-3-13
收藏
得分:0 
回复 2楼 renkejun1942
帮我看看呗,谢谢咯
2017-04-20 16:09
快速回复:最终修订的成绩管理系统
数据加载中...
 
   



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

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