成绩管理程序

功能:
(1) 录入若干个学生每门课程的分数;
(2) 给定学号,显示某位学生所有课程成绩;
(3) 给定某个班级的班号,显示该班所有学生的课程成绩情况;
(4) 给定学号,修改该学生的课程成绩信息;
(5) 按照某门课程的成绩从高到低排序;
(6) 提供一些统计各类信息的功能(例如,某门课程不及格名单、某门课程的总平均成绩等)

关于本程序

  • 连续按三次ctrl z可以返回上一级菜单
  • 请按照正常顺序,一级一级退出,不要直接点击右上角关闭程序。否则,data.txt可能没有完全写入
  • 想即时保存也行,每次操作完成之后加一句writeData(&phead, &ptail);即可
  • 你可以直接在txt中进行修改成绩操作,且不必输入总分、平均分,但一定要保证:格式正确

txt存储格式如下

  • 总人数
  • 学号 姓名 班级 数学 英语 政治 体育 物理 总分 平均分

程序文件构成 (见左侧解决方案资源管理器)

运行环境:vs2017

以下为全部代码

main.c

/* ===================================成绩管理程序===================================* 注意:* 连续按三次ctrl z可以返回上一级菜单* 请按照正常顺序,一级一级退出,不要直接点击右上角关闭程序。否则,data.txt可能没有完全写入* 想即时保存也行,每次操作完成之后加一句writeData(&phead, &ptail);即可* 你可以直接在txt中进行修改成绩操作,且不必输入总分、平均分,但一定要保证:格式正确** txt存储格式如下:* 总人数* 学号 姓名 班级 数学 英语 政治 体育 物理 总分 平均分*==================================================================================*/#include"list.c"
#include"sort.c"
#include"read.c"
#include"write.c"
int main()
{int i;pstu phead = NULL;pstu ptail = NULL;readData(&phead, &ptail);//更新数据(若用户直接操作txt文件,该函数可以自动计算新的总分、平均分)update(&phead, &ptail);//选择想要的操作int choose;while (printHome(), printf("\n请输入你选择的操作:"), scanf("%d", &choose) != EOF){rewind(stdin);system("cls");switch (choose){case 1://增while (system("cls"), list_print(phead, ptail), printf("(三次ctrl z返回上一级)\n请输入要添加的学号:"), scanf("%d", &i) != EOF){rewind(stdin);list_insert_sort(&phead, &ptail, i);}writeData(&phead, &ptail);break;case 2://删while (system("cls"), list_print(phead, ptail), printf("(三次ctrl z返回上一级)\n请输入删除的学号:"), scanf("%d", &i) != EOF){rewind(stdin);list_delete(&phead, &ptail, i);}writeData(&phead, &ptail);break;case 3://改while (system("cls"), list_print(phead, ptail), printf("(三次ctrl z返回上一级)\n请输入修改的学号:"), scanf("%d", &i) != EOF){rewind(stdin);list_modify(&phead, &ptail, i);}writeData(&phead, &ptail);break;case 4://查while (system("cls"), printf("(三次ctrl z返回上一级)\n请输入查找的学号:"), scanf("%d", &i) != EOF){rewind(stdin);list_find(&phead, &ptail, i);}writeData(&phead, &ptail);break;case 5://排序while (system("cls"), printf("(三次ctrl z返回上一级)\n请输入排序依据:\n1总分 2数学 3英语 4政治 5体育 6物理 7学号\n"), scanf("%d", &i) != EOF){rewind(stdin);arr_select(&phead, &ptail, i);list_print(phead, ptail);system("pause");}writeData(&phead, &ptail);break;case 6://统计信息while (system("cls"), printf("(三次ctrl z返回上一级)\n请输入要查看的数据编号:\n(一)不及格名单(小于60分)\n11 数学\n12 英语\n13 政治\n14 体育\n15 物理\n\n(二) 成绩优秀名单(大于90分)\n21 数学\n22 英语\n23 政治\n24 体育\n25 物理\n\n(三) 课程平均成绩\n31 数学\n32 英语\n33 政治\n34 体育\n35 物理\n\n(四) 按班级分类\n41 输出某个班的成绩\n"), scanf("%d", &i) != EOF){rewind(stdin);statistics(&phead, &ptail, i);}break;}}writeData(&phead, &ptail);//鸡肋的保存
}

head.h

#ifndef __FIRST__H_H
#define __FIRST__H_H
#define COURSENUM 5typedef struct student
{int id;char name[20];int classnum;int math;int english;int politics;int sports;int physics;int total;int average;struct student *pnext;
}stu, *pstu;
#endif

list.c

#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<stdlib.h>
#include"head.h"
//打印首页
void printHome()
{system("cls");printf("          * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * **\n");printf("          *                                                              *\n");printf("          *                 学 生 成 绩 管 理 系 统                      *\n");printf("          *                                                              *\n");printf("          * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * **\n");printf("          *        *                         *                           *\n");printf("          *        *      1.添 加 学 生      *      2.删 除 学 生        *\n");printf("          *   功   *                         *                           *\n");printf("          *        * * * * * * * * * * * * * * * * * * * * * * * * * * * *\n");printf("          *   能   *                         *                           *\n");printf("          *        *      3.修 改 成 绩      *      4.查 找 学 生        *\n");printf("          *   菜   *                         *                           *\n");printf("          *        * * * * * * * * * * * * * * * * * * * * * * * * * * * *\n");printf("          *   单   *                         *                           *\n");printf("          *        *      5.按 要 求 排 序   *      6.统 计 信 息        *\n");printf("          *        *                         *                           *\n");printf("          * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * **\n");printf("          *                                                              *\n");printf("          * 提 示 :任 意 界 面 下 , 连 续 三 次 ctrl z 返 回 上 一 级   *\n");printf("          *                                                              *\n");printf("          * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * **\n");}//打印总表
void list_print(pstu phead, pstu ptail)
{int flag = 0;pstu pcur = phead;printf("学号\t姓名\t班级\t数学\t英语\t政治\t体育\t物理\t总分\t平均分\n");while (pcur != NULL){flag = 1;printf("%d\t%s\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\n", pcur->id, pcur->name, pcur->classnum, pcur->math, pcur->english, pcur->politics, pcur->sports, pcur->physics, pcur->total, pcur->average);pcur = pcur->pnext;}flag == 0 || printf("\n");//空表时不打印换行
}//打印当前学生
void printOne(stu one)
{printf("学号\t姓名\t班级\t数学\t英语\t政治\t体育\t物理\t总分\t平均分\n");printf("%d\t%s\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\n", one.id, one.name, one.classnum, one.math, one.english, one.politics, one.sports, one.physics, one.total, one.average);
}
void printOneNoHead(stu one)
{printf("%d\t%s\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\n", one.id, one.name, one.classnum, one.math, one.english, one.politics, one.sports, one.physics, one.total, one.average);
}
//打印统计信息
void statistics(pstu *pphead, pstu *pptail, int i)
{int flag = 0;pstu pcur = *pphead;if ((i >= 11 && i <= 15) || (i >= 21 && i <= 25))//输出成绩优秀名单{printf("学号\t姓名\t班级\t数学\t英语\t政治\t体育\t物理\t总分\t平均分\n");while (pcur != NULL){flag = 1;switch (i){case 11:if (pcur->math < 60)printOneNoHead(*pcur);  break;case 12:if (pcur->english < 60)printOneNoHead(*pcur);  break;case 13:if (pcur->politics < 60)printOneNoHead(*pcur);  break;case 14:if (pcur->sports < 60)printOneNoHead(*pcur);  break;case 15:if (pcur->physics < 60)printOneNoHead(*pcur);  break;case 21:if (pcur->math >= 90)printOneNoHead(*pcur); break;case 22:if (pcur->english >= 90)printOneNoHead(*pcur);  break;case 23:if (pcur->politics >= 90)printOneNoHead(*pcur);  break;case 24:if (pcur->sports >= 90)printOneNoHead(*pcur); break;case 25:if (pcur->physics >= 90)printOneNoHead(*pcur); break;}pcur = pcur->pnext;}system("pause");}//输出单科平均分else if (i >= 31 && i <= 35){//遍历计算总数pcur = *pphead;//这句可能不需要int totalStu = 0;while (pcur != NULL){totalStu++;pcur = pcur->pnext;}//计算pcur = *pphead;//pcur归位float average = 0;switch (i){case 31:printf("数学");while (pcur != NULL){average += pcur->math;pcur = pcur->pnext;}printf("平均分:%.2f", average /= totalStu);system("pause");break;case 32:printf("英语");while (pcur != NULL){average += pcur->english;pcur = pcur->pnext;}printf("平均分:%.2f", average /= totalStu);system("pause");break;case 33:printf("政治");while (pcur != NULL){average += pcur->politics;pcur = pcur->pnext;}printf("平均分:%.2f", average /= totalStu);system("pause");break;case 34:printf("体育");while (pcur != NULL){average += pcur->sports;pcur = pcur->pnext;}printf("平均分:%.2f", average /= totalStu);system("pause");break;case 35:printf("物理");while (pcur != NULL){average += pcur->physics;pcur = pcur->pnext;}printf("平均分:%.2f", average /= totalStu);system("pause");break;}}else if (i == 41){pcur = *pphead;//pcur归位system("cls");printf("请输入班号:\n");scanf("%d", &i);printf("学号\t姓名\t班级\t数学\t英语\t政治\t体育\t物理\t总分\t平均分\n");while (pcur != NULL){if (pcur->classnum == i){printOneNoHead(*pcur);}pcur = pcur->pnext;}system("pause");return;}
}//计算总分和平均分
void AddAndAverage(pstu one)
{one->total = one->english + one->math + one->physics + one->politics + one->sports;one->average = one->total / COURSENUM;
}
//更新总分、平均分
void update(pstu *pphead, pstu *pptail)
{pstu pcur = *pphead;while (pcur != NULL){pcur->total = pcur->english + pcur->math + pcur->physics + pcur->politics + pcur->sports;pcur->average = pcur->total / COURSENUM;pcur = pcur->pnext;}
}
//增:有序插入
void list_insert_sort(pstu *pphead, pstu *pptail, int i)
{pstu pnew;pnew = (pstu)calloc(1, sizeof(stu));pnew->id = i;printf("请输入姓名:");scanf("%s", pnew->name); rewind(stdin);printf("请输入班号:");scanf("%d", &pnew->classnum); rewind(stdin);pnew->math = pnew->english = pnew->politics = pnew->sports = pnew->physics = pnew->total = pnew->average = 0;pstu pcur = *pphead;pstu pbefore = *pphead;if (NULL == *pptail)//如果链表为空{*pphead = pnew;*pptail = pnew;}else{//从小到大if (i <= pcur->id)//如果小于第一个节点,头插{pnew->pnext = *pphead;//新节点的pnext成员指向原有链表头*pphead = pnew;//新节点成为新的链表头return;}else//向后遍历{while (NULL != pcur)//只要不是最后{if (i <= pcur->id){pbefore->pnext = pnew;//小弟的pnext成员指向新节点pnew->pnext = pcur;//新节点的pnext成员指向大哥break;}pbefore = pcur;//小弟记住大哥的脚印pcur = pcur->pnext;//大哥先走一步       }if (NULL == pcur)//如果到最后,尾插{(*pptail)->pnext = pnew;//原有链表尾的pnext成员指向新节点*pptail = pnew;//新节点成为新的链表尾}}}
}//删除
void list_delete(pstu *pphead, pstu *pptail, int i)
{pstu pcur = *pphead;pstu pbefore = *pphead;if (NULL == *pptail)//如果链表为空{printf("链表为空\n");}else if (i == (*pphead)->id)//如果等于第一个节点(此时可能仅剩一个节点){*pphead = (*pphead)->pnext;//头指针指向下一个节点if (NULL == *pphead){*pptail = NULL;free(pcur);}}else//如果不等于第一个节点{while (NULL != pcur)//只要不是最后{if (i == pcur->id)//如果等于当前节点{pcur = pcur->pnext;//大哥前进一步pbefore->pnext = pcur;//小弟的pnext成员指向大哥return;}else{pbefore = pcur;//小弟记住大哥的脚印pcur = pcur->pnext;//大哥先走一步        }}if (NULL == pcur)//如果到最后{printf("不存在此学号\n");}}
}//修改
void list_modify(pstu *pphead, pstu *pptail, int i)
{int score;pstu pcur = *pphead;pstu pbefore = *pphead;if (NULL == *pptail)//如果链表为空{printf("链表为空\n");}else{while (NULL != pcur)//只要不是最后{if (i == pcur->id)//如果等于当前节点,修改{int sub;printOne(*pcur);while (printf("请选择科目(输入科目代号):1高数 2英语 3政治 4体育 5物理\n")){if (scanf("%d", &sub) == EOF){rewind(stdin);return;}printf("请输入分数:");scanf("%d", &score);switch (sub){case 1:pcur->math = score; AddAndAverage(pcur); printOne(*pcur); break;case 2:pcur->english = score; AddAndAverage(pcur); printOne(*pcur); break;case 3:pcur->politics = score; AddAndAverage(pcur); printOne(*pcur); break;case 4:pcur->sports = score; AddAndAverage(pcur); printOne(*pcur); break;case 5:pcur->physics = score; AddAndAverage(pcur); printOne(*pcur); break;}}}else{pbefore = pcur;//小弟记住大哥的脚印pcur = pcur->pnext;//大哥先走一步      }}if (NULL == pcur)//如果到最后{printf("不存在此学号\n");}}
}
//查找
void list_find(pstu *pphead, pstu *pptail, int i)
{pstu pcur = *pphead;pstu pbefore = *pphead;if (NULL == *pptail)//如果链表为空{printf("链表为空\n");system("pause");}else{while (NULL != pcur)//只要不是最后{if (i == pcur->id)//如果等于当前节点,输出{printOne(*pcur);system("pause");return;}else{pbefore = pcur;//小弟记住大哥的脚印pcur = pcur->pnext;//大哥先走一步        }}if (NULL == pcur)//如果到最后{printf("不存在此数字\n");}}
}

sort.c

#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<stdlib.h>
#include"head.h"//按总分 选择排序
void arr_select(pstu *pphead, pstu *pptail, int subject)//sunject排序依据 1总分 2数学 3英语 4政治 5体育 6物理
{int t;pstu temp = (pstu)calloc(1, sizeof(stu));//这里不能强行将temp赋给任何(无意义的)变量,必须申请新的空间。否则temp的值会在swap的时候漂移pstu pleft = *pphead;pstu pright = *pphead;pstu prightmax = NULL;if (NULL == *pptail)//如果链表为空{printf("链表为空\n");system("pause");}else{for (; pleft != NULL; pleft = pleft->pnext)//最大的数放在左边{pright = pleft;for (prightmax = pright; pright != NULL; pright = pright->pnext)//从右边找出最大的数,用prightmax记录其位置{switch (subject){case 1:if (pright->total > prightmax->total){prightmax = pright;}break;case 2:if (pright->math > prightmax->math){prightmax = pright;}break;case 3:if (pright->english > prightmax->english){prightmax = pright;}break;case 4:if (pright->politics > prightmax->politics){prightmax = pright;}break;case 5:if (pright->sports > prightmax->sports){prightmax = pright;}break;case 6:if (pright->physics > prightmax->physics){prightmax = pright;}break;case 7:if (pright->id < prightmax->id){prightmax = pright;}break;}}//SWAP(*pleft, *prightmax)(*temp).id = pleft->id;for (t = 0; t < 20; t++)//迷之复制字符串{(*temp).name[t] = pleft->name[t];}(*temp).classnum = pleft->classnum;(*temp).math = pleft->math;(*temp).english = pleft->english;(*temp).politics = pleft->politics;(*temp).sports = pleft->sports;(*temp).physics = pleft->physics;(*temp).total = pleft->total;(*temp).average = pleft->average;pleft->id = prightmax->id;for (t = 0; t < 20; t++)//迷之复制字符串{pleft->name[t] = prightmax->name[t];}pleft->classnum = prightmax->classnum;pleft->math = prightmax->math;pleft->english = prightmax->english;pleft->politics = prightmax->politics;pleft->sports = prightmax->sports;pleft->physics = prightmax->physics;pleft->total = prightmax->total;pleft->average = prightmax->average;prightmax->id = (*temp).id;for (t = 0; t < 20; t++)//迷之复制字符串{prightmax->name[t] = (*temp).name[t];}prightmax->classnum = (*temp).classnum;prightmax->math = (*temp).math;prightmax->english = (*temp).english;prightmax->politics = (*temp).politics;prightmax->sports = (*temp).sports;prightmax->physics = (*temp).physics;prightmax->total = (*temp).total;prightmax->average = (*temp).average;}}
}

read.c

#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<stdlib.h>
#include"head.h"void readData(pstu *pphead, pstu *pptail)
{int TOTAL;pstu pcur = *pphead;pstu pbefore = *pphead;pstu pnew;FILE *fpReadAgain = fopen("data.txt", "r");//读取fscanf(fpReadAgain, "%d", &TOTAL);for (int j = 0; j < TOTAL; j++){pcur = *pphead;pbefore = *pphead;pnew = (pstu)calloc(1, sizeof(stu));//只申请一个fscanf(fpReadAgain, "%d %s %d %d %d %d %d %d %d %d", &pnew->id, &pnew->name, &pnew->classnum, &pnew->math, &pnew->english, &pnew->politics, &pnew->sports, &pnew->physics, &pnew->total, &pnew->average);if (NULL == *pptail)//如果链表为空{*pphead = pnew;*pptail = pnew;//不用担心尾节点不是NULL,因为calloc的pnew中的pnext成员本身就是null}else{(*pptail)->pnext = pnew;//原有链表尾的pnext成员指向新节点*pptail = pnew;//新节点成为新的链表尾}}fclose(fpReadAgain);
}

write.c

#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<stdlib.h>
#include"head.h"
void writeData(pstu *pphead, pstu *pptail)
{int TOTAL = 0;//计算链表长度pstu pcur = *pphead;while (pcur != NULL){TOTAL++;pcur = pcur->pnext;}FILE *fpPrintAgain = fopen("data.txt", "w");//输出fprintf(fpPrintAgain, "%d\n", TOTAL);//输出总数据量,便于下一次读取pcur = *pphead;while (pcur != NULL){fprintf(fpPrintAgain, "%d %s %d %d %d %d %d %d %d %d\n", pcur->id, pcur->name, pcur->classnum, pcur->math, pcur->english, pcur->politics, pcur->sports, pcur->physics, pcur->total, pcur->average);pcur = pcur->pnext;}fclose(fpPrintAgain);
}

C语言课设 成绩管理程序相关推荐

  1. c语言课设学生管理程序,c语言程序课程设计学生成绩管理程序.doc

    c语言程序课程设计学生成绩管理程序 武汉科技大学 二〇一〇~二〇一一学年第一学期 信息科学与工程学院 课程设计报告书 课程名称: C语言课程设计 班 级: 自动化2009级2班 学 号: 姓 名: 指 ...

  2. c语言课设宿舍管理程序,C语言程序课程设计宿舍管理软件.doc

    C语言程序课程设计宿舍管理软件.doc 课程设计(论文) 题 目 名 称 宿舍管理软件 课 程 名 称 C语言程序课程设计 学 生 姓 名 学 号 系 .专 业 信息工程系.信息大类 指 导 教 师 ...

  3. c语言学生成绩查询课设报告,C语言课设报告(学生考试成绩查询程序)【荐】.doc...

    C语言课设报告(学生考试成绩查询程序)[荐].doc 学生考试成绩查询程序 学号:******** 姓名:***** 完成日期:****年月 通过键盘输入学生的考试信息,包括:学号.姓名.课程名称.学 ...

  4. c语言学生学籍管理修改,C语言课设之学生学籍管理系统.doc

    C语言课设之学生学籍管理系统.doc 题目学生学籍管理系统 目录一.个人简介.二.报告摘要.三.报告目录.四.报告正文. 1.系统需求分析 2.系统总体设计 3.系统详细设计六.总结. 二.报告摘要 ...

  5. 课设 c语言编译学籍管理系统,C语言课设之学生学籍管理系统

    <C语言课设之学生学籍管理系统>由会员分享,可在线阅读,更多相关<C语言课设之学生学籍管理系统(10页珍藏版)>请在人人文库网上搜索. 1.题目:学生学籍管理系统 目录:一.个 ...

  6. 学生信息管理系统c语言课设,学生信息管理系统C语言课设.doc

    学生信息管理系统C语言课设 目录 一.需求分析2 二.概要设计2 三.详细设计4 四.调试分析9 五.用户手册9 六.测试数据9 七.附录10 一.需求分析学生学籍管理系统用数据文件存放学生的学籍,可 ...

  7. C语言课设物资管理系统,C语言课设之物资管理系统.doc

    C语言课设之物资管理系统 C语言课程设计 目 录 1.需求分析: 2.系统总框图: 3.每个模块的设计分析: 4.列出所有定义的函数及说明: 5.举例说明1.2个比较有特点的算法: 6.数据分析.完备 ...

  8. 电影院选票系统(C语言课设)

    这里给到大家介绍一个自己写的C语言课设的代码,代码功能不是很完善,只有很基础的增删改查 题目 :电影院选票系统 功能 :放映厅 ,电影信息的 增删改查,以及排序 系统要求实现以下功能: 1.输入功能: ...

  9. c语言售票系统主要函数,c语言课设电影院售票系统.docx

    struct inf { char rate[20]; char name[20]; int time_hour; int time_min; int seat; int sell; }inf[10] ...

最新文章

  1. 【Android NDK 开发】JNI 线程 ( JNI 线程创建 | 线程执行函数 | 非 JNI 方法获取 JNIEnv 与 Java 对象 | 线程获取 JNIEnv | 全局变量设置 )
  2. mysql慢查询日志时间戳_Mysql查询在时间戳的日期范围内非常慢
  3. C语言学习之用*打印菱形
  4. c++ vector拷贝构造_JDK源码分析-Vector
  5. 3. 无重复字符的最长子串 golang
  6. gns3中怎么把服务器虚拟化,GNS3使用详解(gns3如何模拟ids)
  7. Adobe Flash离线安装包下载
  8. 移动硬盘坏点测试软件,移动硬盘坏道检测修复
  9. 20172301 2017-2018-2 《程序设计与数据结构》第六周学习总结
  10. 如何快速一键重装系统 一键重装系统图文教程
  11. 基于springboot+dubbo微服务开发的商城系统
  12. matlab 524288,Cannot display summaries of variables with more than 524288 elements. 怎么...
  13. su [user] 和 su - [user]的区别
  14. Java new一个对象
  15. 准备入手iPhone 4港版的必看!港行无锁版iPhone 4购买全攻略
  16. 赠与今年的大学毕业生,胡适
  17. linux分区写保护,mtd分区写保护关闭
  18. 服务器内存与CPU的搭配
  19. 中国计算机发展的历史和现状
  20. QLineEdit 判断是否为用户输入

热门文章

  1. 动态规划算法-07背包问题进阶
  2. [USACO18JAN][luoguP4183 ]Cow at Large P
  3. C语言实现缓冲区溢出实例
  4. IDA来远程调试Linux程序
  5. EventBus设计与实现分析——订阅者的注册
  6. 高级数据结构与算法 | 深度遍历搜索(DFS)与广度遍历搜索(BFS)
  7. 第45讲:哪都能存,Item Pipeline 的用法
  8. spring源码构建以及模块划分和依赖
  9. 经典永驻,重温设计模式 |硬核!
  10. Kafka科普系列 | 什么是LSO?