精华内容
参与话题
问答
  • C语言开发简单的学生成绩管理系统(附源码)

    万次阅读 多人点赞 2019-04-15 21:08:22
    学生成绩管理系统 开发语言:C语言 开发工具:Visual Studio 2019 开发时间:2019.4.14 开发者:summer @一、系统使用展示 @二、系统功能 @三、菜单 @四、录入学生信息 @五、打印学生信息 @六、保存学生信息 @七、...

    学生成绩管理系统

    开发语言:C语言
    开发工具:Visual Studio 2019
    开发时间:2019.4.14
    开发者:summer
    CSDN源码下载:C语言开发简单的学生成绩管理系统
    Github项目源码下载:C语言开发简单的学生成绩管理系统
    百度网盘源码下载:链接:https://pan.baidu.com/s/1nF53PtRtbuFCNvG7hfylPw 提取码:ar5g

    @一、系统使用展示

    @二、系统功能

    @三、菜单

    @四、录入学生信息

    @五、打印学生信息

    @六、保存学生信息

    @七、读取学生信息

    @八、统计所有学生人数

    @九、查找学生信息

    @十、修改学生信息

    @十一、删除学生信息

    @十二、退出系统

    @十三、出错

    一、系统使用展示

    Alt

    二、系统功能

    1. 系统功能介绍
    1.录入学生信息:用户可以自由输入学生信息到系统中。
    2.打印学生信息:格式化展示系统中的学生信息。
    3.保存学生信息:将系统中的学生信息保存到本地文档。
    4.读取学生信息:读取本地文档中的学生信息并显示。
    5.统计所有学生人数
    6.查找学生信息:根据用户给定的信息(学号)在系统中查找该学生的信息
    7.修改学生信息
    8.删除学生信息
    0.退出系统
    
    1. 系统main函数,while循环在外,系统程序能够持续运行,switch判断语句进行功能选择与函数切换。
    int main() {
    	while (1)
    	{
    		//打印菜单
    		Menu();
    		//读取一个字符 整数,字符在内存中映射为ASCII码
    		char ch = _getch();
    
    		switch (ch)
    		{
    		case '1'://1.录入学生信息
    			InputStudent();
    			break;
    		case '2'://2.打印学生信息
    			PrintStudent();
    			break;
    		case '3'://3.保存学生信息
    			SaveStudent();
    			break;
    		case '4'://4.读取学生信息
    			ReadStudent();
    			break;
    		case '5'://5.统计所有学生人数
    			CountStudent();
    			break;
    		case '6'://6.查找学生信息
    			FindStudent();
    			break;
    		case '7'://7.修改学生信息
    			ChangeStudent();
    			break;
    		case '8'://8.删除学生信息
    			DeleteStudent();
    			break;
    		case '0'://0.退出系统
    			return 0;
    			break;
    		default:
    			printf("输入有误,没有该功能\n\n");
    			system("pause");  //暂停
    			system("cls");    //清屏
    			break;
    		}
    	}
    
    	return 0;
    }
    

    三、菜单

    1. 菜单显示
    //菜单
    void Menu() {
    	printf("*************************************************\n");
    	printf("*\t欢迎使用高校学生成绩管理系统V1.0\t*\n");
    	printf("*\t\t请选择功能\t\t\t*\n");
    	printf("*************************************************\n");
    	printf("*\t\t1.录入学生信息\t\t\t*\n");
    	printf("*\t\t2.打印学生信息\t\t\t*\n");
    	printf("*\t\t3.保存学生信息\t\t\t*\n");
    	printf("*\t\t4.读取学生信息\t\t\t*\n");
    	printf("*\t\t5.统计所有学生人数\t\t*\n");
    	printf("*\t\t6.查找学生信息\t\t\t*\n");
    	printf("*\t\t7.修改学生信息\t\t\t*\n");
    	printf("*\t\t8.删除学生信息\t\t\t*\n");
    	printf("*\t\t0.退出系统\t\t\t*\n");
    	printf("*************************************************\n");
    }
    
    1. 打印菜单

    scanf()、getchar()输入后均需要按enter,而getch()不用

    	//打印菜单
    	Menu();
    	//读取一个字符 整数,字符在内存中映射为ASCII码
    	char ch = _getch();
    

    四、录入学生信息

    1. 定义学生结构体、链表节点结构体
    //定义一个学生
    typedef struct tagStudent {
    	char szName[20];	//姓名
    	char szSex[4];		//性别
    	int  nAge;			//年龄
    	int  nStuNo;		//学号
    	int  nScore;		//成绩
    }Student;
    
    //链表
    //节点
    typedef struct tagNode
    {
    	Student stu;			//学生信息
    	struct tagNode* pNext;	//指向下一个节点
    }Node;
    
    //创建头节点
    Node* g_pHead = NULL;		//指向头节点
    
    1. 利用学生结构体,以及链表操作输入学生信息
    //1.录入学生信息
    void InputStudent() {
    	//创建一个人,在堆中分配内存
    	Node* pNewNode = (Node*)malloc(sizeof(Node));
    	//指针下一个指向空
    	pNewNode->pNext = NULL;
    
    	//查找链表的尾结点
    	Node* p = g_pHead;
    	while (g_pHead != NULL && p->pNext != NULL)
    	{
    		p = p->pNext;
    	}
    
    	//把节点插到链表的尾节点
    	if (g_pHead == NULL) {
    		g_pHead = pNewNode;
    	}
    	else {
    		p->pNext = pNewNode;
    	}
    
    	//录入学生信息
    	printf("请输入学生姓名:\n");
    	scanf_s("%s", pNewNode->stu.szName, sizeof(pNewNode->stu.szName));
    	printf("请输入性别:\n");
    	scanf_s("%s", pNewNode->stu.szSex, sizeof(pNewNode->stu.szSex));
    	printf("请输入学生年龄:\n");
    	scanf_s("%d", &pNewNode->stu.nAge);
    	printf("请输入学号:\n");
    	scanf_s("%d", &pNewNode->stu.nStuNo);
    	printf("请输入成绩:\n");
    	scanf_s("%d", &pNewNode->stu.nScore);
    
    	printf("学生信息录入成功。\n\n");
    	system("pause");
    	system("cls");
    }
    

    五、打印学生信息

    1. 读取链表结构,输出学生信息。先进行判空处理,如果无学生信息则输出提示信息,反之则正确输出学生信息。
    //2.打印学生信息
    void PrintStudent() {
    
    	system("cls");
    	//遍历链表
    	Node* p = g_pHead;
    	if (p == NULL) {
    		printf("系统中暂无学生信息,请录入后再来打印查看。\n\n");
    	}
    	else {
    		printf("*********************************************************************************\n");
    		printf("*\t\t\t欢迎使用高校学生成绩管理系统V1.0\t\t\t*\n");
    		printf("*********************************************************************************\n");
    		printf("*\t学号\t*\t姓名\t*\t性别\t*\t年龄\t*\t成绩\t*\n");
    		printf("*********************************************************************************\n");
    
    		while (p != NULL)
    		{
    			printf("*\t%d\t*\t%s\t*\t%s\t*\t%d\t*\t%d\t*\n",
    				p->stu.nStuNo,
    				p->stu.szName,
    				p->stu.szSex,
    				p->stu.nAge,
    				p->stu.nScore
    			);
    
    			//下一个节点
    			p = p->pNext;
    			printf("*********************************************************************************\n");
    		}
    	}
    
    	system("pause");
    	system("cls");
    }
    

    六、保存学生信息

    1. 利用文件对学生信息进行存储
    //3.保存学生信息
    void SaveStudent() {
    	//打开文件
    	FILE* pFile;
    	pFile = fopen(".\\stuinfo.dat", "w");
    	
    	if (pFile == NULL) {
    		printf("打开文件失败。\n");
    		return;
    	}
    
    	//写入数据
    	Node* p = g_pHead;
    	while (p != NULL)
    	{
    		fwrite(&p->stu, sizeof(Node), 1, pFile);
    		p = p->pNext;
    	}
    
    	//关闭文件
    	fclose(pFile);
    
    	printf("数据保存成功。\n");
    	system("pause");
    	system("cls");
    }
    
    1. fopen在vs中会报错,解决方式

    (1)按照vs的提示,将fopen换成fopen_s

    (2)不修改函数,仅仅修改项目的属性。因为fopen_s是一种Microsoft的函数,若纯做Windows开发则直接改为_s也无妨,但是我们尽量还是用标准C++比较好,这样代码有较好的移植性。

    具体操作:

    右键工程名–>属性–>C/C++–>预处理器–>预处理器定义,编辑右边输入框加入: _CRT_SECURE_NO_WARNINGS

    保存(注意用分号隔开)。

    七、读取学生信息

    1. 打开存储学生信息的文本,单个单词读取,判断非分隔符或者空时则赋值给链表中的节点,读取完毕后,直接调用PrintStudent()函数进行打印结果。
    //4.读取学生信息
    void ReadStudent() {
    	system("cls");
    
    	//打开文件
    	FILE* pFile;
    	pFile = fopen(".\\stuinfo.dat", "r");
    
    	if (pFile == NULL) {
    		printf("打开文件失败。\n");
    		return;
    	}
    	
    	//创建一个人,在堆中分配内存
    	Node* p = (Node*)malloc(sizeof(Node));
    	p->pNext = NULL;
    	//重新建立链表
    	g_pHead = p;
    
    	//逐个单词读入文本内容
    	char str[200];
    	int i = 0;
    	while (fscanf(pFile, "%s", str) != EOF) {  //读文件 
    		//单词不是*或者空时,进行赋值
    		if (strcmp(str, "*") && str != NULL) {
    			switch (i)
    			{
    			case 0:
    				p->stu.nStuNo = atoi(str);
    				break;
    			case 1:
    				strcpy(p->stu.szName, str);
    				break;
    			case 2:
    				strcpy(p->stu.szSex, str);
    				break;
    			case 3:
    				p->stu.nAge = atoi(str);
    				break;
    			case 4:
    				p->stu.nScore = atoi(str);
    				break;
    			default:
    				Node* pNewNode = (Node*)malloc(sizeof(Node));
    				pNewNode->pNext = NULL;
    				p->pNext = pNewNode;
    				p = pNewNode;
    				p->stu.nStuNo = atoi(str);
    				i = 0;
    				break;
    			}
    			i++;
    		}
    	}
    	//打印读取结果
    	PrintStudent();
    }
    
    1. 读取文本时,将内容全部赋值给char数组,所有赋值时需特殊处理。
    • char数组赋值给整数

      在<stdlib.h>头文件中有两个函数,int atoi(char *p)和char *itoa(int p),分别将装有整数的char数组转化为整数,和将整数按位数分解依次存入char数组中。

    • char数组赋值给char数组

      用strcpy函数!

      原型声明:extern char *strcpy(char *dest,char *src);

      头文件:string.h

      功能:把src所指由NULL结束的字符串复制到dest所指的数组中。

      说明:src和dest所指内存区域不可以重叠且dest必须有足够的空间来容纳src的字符串。

      返回指向dest的指针。

      注:不能使用memcpy(a, b, strlen(b)),会导致中文乱码。

    八、统计所有学生人数

    1. 设置计数器,遍历链表
    //5.统计所有学生人数
    void CountStudent() {
    	int countStu = 0;
    
    	//遍历链表
    	Node* p = g_pHead;
    	while (p != NULL)
    	{
    		countStu++;
    		p = p->pNext;
    	}
    	printf("学生总人数:%d\n\n", countStu);
    
    	system("pause");
    	system("cls");
    }
    

    九、查找学生信息

    1. 本次查找以学号为示例,改用姓名等信息查询流程基本一致。

      遍历链表,如果有符合信息的学生则打印,反之则继续下一个节点,若系统中无该学生信息,给予用户无结果提示。

    //6.查找学生信息
    void FindStudent() {
    	system("cls");
    	//以学号为查找示例,其他信息查找流程基本相似
    	int stuNum;
    	printf("请输入查找学生学号:");
    	scanf("%d", &stuNum);
    	//遍历链表查找,查找到后进行信息显示
    	Node* p = g_pHead;
    	//对表头进行展示一次
    	bool isShowHead = false;
    	//记录是否有找到该学号的学生信息
    	bool isFindStu = false;
    	while (p != NULL)
    	{
    		if (stuNum == p->stu.nStuNo) {
    			if (!isShowHead) {
    				printf("*********************************************************************************\n");
    				printf("*\t学号\t*\t姓名\t*\t性别\t*\t年龄\t*\t成绩\t*\n");
    				printf("*********************************************************************************\n");
    				isShowHead = true;
    			}
    			printf("*\t%d\t*\t%s\t*\t%s\t*\t%d\t*\t%d\t*\n",
    				p->stu.nStuNo,
    				p->stu.szName,
    				p->stu.szSex,
    				p->stu.nAge,
    				p->stu.nScore
    			);
    			isFindStu = true;
    			printf("*********************************************************************************\n");
    		}
    		p = p->pNext;
    	}
    
    	if (!isFindStu) {
    		printf("学号输入有误,系统中暂无该学生信息。\n\n");
    	}
    
    	system("pause");
    	system("cls");
    }
    

    十、修改学生信息

    1. 可参考查找学生信息代码段,在查找后进行修改即可
    //7.修改学生信息
    void ChangeStudent() {
    	//以学号为查找示例,其他信息查找流程基本相似
    	int stuNum;
    	printf("请输入欲修改学生的学号:");
    	scanf("%d", &stuNum);
    	//遍历链表查找,查找到后进行信息显示
    	Node* p = g_pHead;
    	//对表头进行展示一次
    	bool isShowHead = false;
    	//记录是否有找到该学号的学生信息
    	bool isFindStu = false;
    	while (p != NULL)
    	{
    		if (stuNum == p->stu.nStuNo) {
    			if (!isShowHead) {
    				printf("*********************************************************************************\n");
    				printf("*\t学号\t*\t姓名\t*\t性别\t*\t年龄\t*\t成绩\t*\n");
    				printf("*********************************************************************************\n");
    				isShowHead = true;
    			}
    			printf("*\t%d\t*\t%s\t*\t%s\t*\t%d\t*\t%d\t*\n",
    				p->stu.nStuNo,
    				p->stu.szName,
    				p->stu.szSex,
    				p->stu.nAge,
    				p->stu.nScore
    			);
    			//修改学生信息
    			printf("请输入学生姓名:\n");
    			scanf_s("%s", p->stu.szName, sizeof(p->stu.szName));
    			printf("请输入性别:\n");
    			scanf_s("%s", p->stu.szSex, sizeof(p->stu.szSex));
    			printf("请输入学生年龄:\n");
    			scanf_s("%d", &p->stu.nAge);
    			printf("请输入学号:\n");
    			scanf_s("%d", &p->stu.nStuNo);
    			printf("请输入成绩:\n");
    			scanf_s("%d", &p->stu.nScore);
    			isFindStu = true;
    			printf("*********************************************************************************\n");
    			printf("学生信息修改成功,请注意及时保存。\n\n");
    		}
    		p = p->pNext;
    	}
    
    	if (!isFindStu) {
    		printf("学号输入有误,系统中暂无该学生信息,无法进行修改。\n\n");
    	}
    
    	system("pause");
    	system("cls");
    }
    

    十一、删除学生信息

    1. 仍然以查找学生信息操作为基础,以学号为线索,查找到则进行删除,未查找到则进行错误提示,删除时需要区分当前节点是头结点、尾节点或者中间节点,不同节点操作不同,同时该删除仅作用于本次操作,需保存学生信息才能长久生效。
    //8.删除学生信息
    void DeleteStudent() {
    	system("cls");
    	//以学号为查找示例,其他信息查找流程基本相似
    	int stuNum;
    	printf("请输入删除学生的学号:");
    	scanf("%d", &stuNum);
    	//遍历链表查找,查找到后进行信息显示
    	Node* p = g_pHead;
    	//记录前一个节点,删除时方便操作
    	Node* beforeNode = g_pHead;
    
    	//对表头进行展示一次
    	bool isShowHead = false;
    	//记录是否有找到该学号的学生信息
    	bool isFindStu = false;
    	while (p != NULL)
    	{
    		if (stuNum == p->stu.nStuNo) {
    			if (!isShowHead) {
    				printf("*********************************************************************************\n");
    				printf("*\t学号\t*\t姓名\t*\t性别\t*\t年龄\t*\t成绩\t*\n");
    				printf("*********************************************************************************\n");
    				isShowHead = true;
    			}
    			printf("*\t%d\t*\t%s\t*\t%s\t*\t%d\t*\t%d\t*\n",
    				p->stu.nStuNo,
    				p->stu.szName,
    				p->stu.szSex,
    				p->stu.nAge,
    				p->stu.nScore
    			);
    			isFindStu = true;
    			printf("*********************************************************************************\n");
    
    			//删除节点为头节点
    			if (p == g_pHead) {
    				g_pHead = p->pNext;
    			}
    			//删除节点为尾节点
    			else if (p->pNext == NULL) {
    				p = beforeNode;
    				p->pNext = NULL;
    			}
    			//删除节点为中间节点
    			else {
    				beforeNode->pNext = p->pNext;
    			}
    			printf("删除成功,请记得保存。\n\n");
    		}
    		beforeNode = p;
    		p = p->pNext;
    	}
    
    	if (!isFindStu) {
    		printf("学号输入有误,系统中暂无该学生信息,无法进行删除操作。\n\n");
    	}
    
    	system("pause");
    	system("cls");
    }
    

    十二、退出系统

    直接在选择0时,设置return即可。

    十三、出错

    用户输入有误时,进行提示信息输出即可。

    	printf("输入有误,没有该功能\n\n");
    	system("pause");  //暂停
    	system("cls");    //清屏
    

    展开全文
  • 1.系统功能分析 1.1系统信息要求 1)学生基本信息如下: 学号、姓名、宿舍号、性别、年龄; 学号为标准格式1234567890十位,其中前两位代表学生入学年份,3-4位代表学生所在学院,5-6位代表学生所学专业、7-8...

    目录

    1.系统功能分析

      1.1系统信息要求

    1.2功能分析

    1.3奖学金评选标准

    2.系统设计

    3.运行效果图

    4.测试数据:

    5.文件说明:

    6.源代码


    1.系统功能分析

      1.1系统信息要求

        1)学生基本信息如下:

        学号、姓名、宿舍号、性别、年龄;

    学号为标准格式1234567890十位,其中前两位代表学生入学年份,3-4位代表学生所在学院,5-6位代表学生所学专业、7-8位代表学生所在班级,9-10位代表学生在班级中的序号。

    姓名最多为4个汉字;

    性别为“男”或“女”;

    年龄为2位正整数

        2)课程信息如下:

    课程号、课程类别、课程所在学期、课程名称、学分;

    课程号为标准课号。例如B08010100;

    课程类别为:选修/必修

    所在学期用阿拉伯数字1-8代表

    课程名称为专业为2014版人才培养计划中的课程名称

    3)学生成绩信息如下:

    学号、课程号、课程成绩、是否重修

    学号为学生信息中的主关键字,可以唯一识别学生。课程号为课程信息的主关键字,可以唯一识别课程。是否重修用于判断课程成绩是否是第一次考试取得。

    4)综合信息

    学号、姓名、获奖类别、获奖时间、惩处类别、惩处时间、所获学分、奖励分值、惩罚分值。奖惩分起始值均为0分。

    1.2功能分析

      1.2.1录入部分

    1)能实现学生信息的录入、修改并保存;

    2)能实现课程信息的录入、修改并保存;

    3)能分学期录入品行表现成绩(辅导员、班主任、班级评议)、修改并保存

    4)能实现课程成绩的录入,并且在实现某课程成绩录入时,能够自动按学号排好顺序,并提示“某学号、某同学 某门功课成级”,例如“1508100201 丁兆元 C语言程序设计A成绩”。

    5)能录入学生的各种奖惩信息

     

     1.2.2修改部分

    1)能对录入的课程成绩进行修改,例如成绩录错、重考、重修原因引起的成绩更改等。

    2)能对个人信息进行修改

    3)能对课程信息进行修改

    4)能对学生奖惩信息进行修改

      1.2.3统计分析部分

    1)能对某门功课各分数段成绩进行统计

    2)能分学期对学生业务课程平均分按分数段进行统计

    3)能统计任意一名同学每门功课的班级排名以及业务课成绩总体排名

    4)能以宿舍为单位进行成绩统计分析

    5)能以挂科次数为依据分学期对比分析

    6)能以业务课班级排名为依据分学期对比分析(前进或退步情况)

      1.2.4排序部分

    1)分学期按业务课程成绩对学生由高到低排序,并显示业务成绩平均分。

    2)分学期按不及格门次对学生由高到低排序,并显示不及格门次。

    3)分学期按不及格学生数对课程进行由高到低排序,并显示课程名及不及格学生数。

    4)能分学期以宿舍为单位按成绩由高到低进行排序,并显示宿舍平均成绩。

    5)能随时根据奖励对学生进行由高到低排序并输出信息。

    6)能随时根据惩罚情况对学生由低到高排序并输出信息。

      1.2.5奖学金自动评定

    能根据学校奖学金评选办法,分学期进行奖学金评定并显示,并能够将评选结果自动追加到学生的奖惩信息库。

      1.2.6数据的导入导出

    基础数据一次录入永久存放,在需要时导入内存变量,如有修改重新导入文件,使永久保存的数据与临时使用的数据保持一致性。

    1.3奖学金评选标准

    1.3.1奖学金评选资格。有下列情形之一者,不能获得奖学金:

    1)品行表现测评名次在班级70%以后者;

    2)必修课或选修课有不及格者;

    3)未达到《大学生体育锻炼合格标准》者;

    4)受警告以上处分者,半年或察看期内不得参加奖学金评选;

    5)品行表现具有不宜获得奖学金的其他情形者。

    1.3.2综合奖学金的评选

    该奖项用于奖励品学兼优、素质全面发展的优秀学生。

    (1)奖励等级、金额、比例为:

    特等奖2000元/人•年 3‰

    一等奖1200元/人•年 3%

    二等奖700元/人•年7%

    三等奖400元/人•年15%

    (2) 一、二、三等奖学金

    以班级为单位,根据综合测评名次排列,列前35%名次者可参评奖学金。一、二、三等奖学金不全部评选的班级,可按学生数的3%、7%、15%的比例,只评选其中的一个等级。

    1.4综合成绩计算标准

         奖励分值计算办法,起始分值为0分。

        (1)奖学金计分:

         获得单项奖学金+1,三等奖学金+2,二等奖学金+3,一等奖学金+4,特等奖学金+5,校长奖学金+6。

        (2)荣誉积分:

    校级各种优秀个人+3,省级各种个人优秀+6,国家级各种优秀+12;

        (3)学科竞赛:

    省级以上学科竞赛成功参赛奖+1,省级三等奖+4、省二等奖+5、生一等奖+6,国家级三等奖+6、国家级二等奖+9、国家级一等奖+12,校级三等奖+1.校级二等奖+2,校级一等奖+3分。

    (4)惩罚分值计算办法,起始分值为0分。

    学院通报批评-1,校级警告-2,严重警告-3,记过-4,记大过-5,开除学籍留校察看-6。

     

    2.系统设计

                                             

                                              

    3.运行效果图【界面太多,文章中只放两个示例】

     

    4.测试数据:

    4.1 账号、密码

    账号:Headmaster

    密码:123456

     4.2 输入测试数据

        (1)学生基本信息

              存于“student.txt”文件。

        (2)课程信息

               存于“subject.txt”文件。

        (3)课程成绩信息

               C语言程序设计:存于“C语言程序设计.txt”文件。

                高等数学1:存于“高等数学_1.txt”文件。

               大学英语1:存于“大学英语_1.txt”文件。

               计算机导论:存于“计算机导论_1.txt”文件。

               大学英语2:存于“大学英语_2.txt”文件。

               离散数学:存于“离散数学_2.txt”文件。

           (4)学生品行成绩信息

                 存于“stCondSc.txt”文件。

           (5)学生综合信息

                存于“cominfo.txt”文件。

    5.文件说明:

    6.下面附上源代码

    【运行前需要自行新建所需文件,必要时自己加上测试数据】

    #include <iostream>
    #include <cstdio>
    #include <cstdlib>
    #include <cstring>
    #include <conio.h>
    
    using namespace std;
    
    //学生基本信息
    struct student
    {
        int stage; //年龄
        char stnum[12]; //学号
        char stname[20]; //姓名
        char stsex[6]; //性别
        char dornum[10]; //宿舍号
        struct student *next;
    };
    
    //课程信息
    struct subject
    {
        char subNum[20]; //课程编号
        char subName[30]; //课程名
        char cate[20]; //课程类别(选修、必修)
        int term; //课程所在学期
        float credit; //学分
        struct subject *next;
    };
    
    //学生成绩信息
    struct stscore
    {
        char stnum[12]; //学号
        char subNum[20]; //课程编号
        int mark; //课程成绩
        char repair[4]; //是否重修
        int cnt = 0; //不及格门次
        struct stscore *next;
    };
    
    //学生品行分信息
    struct stCondSc
    {
        char stnum[12]; //学号
        int coumark; //品行成绩——辅导员
        int headmark; //品行成绩——班主任
        int classsmark; //品行成绩——班级
        int conductmark; //品行分总分
        struct stCondSc *next;
    };
    
    //学生综合信息
    struct cominfo
    {
        char stnum[12]; //学号
        char stname[20]; //姓名
        char awdlev[10]; //获奖类别
        int ayear, amon, aday; //获奖时间
        int amark; //奖励分值
        char puncate[10]; //惩处类别
        int pyear, pmon, pday; //惩处时间
        int pmark; //惩罚分值
        int getcredit; //所获学分
        struct cominfo *next;
    };
    
    struct student *st;//学生基本信息
    struct subject *sub;//课程信息
    struct stscore *stsc;//学生成绩信息
    struct cominfo *coin;//学生综合信息
    struct stCondSc *stcosc; //学生品行成绩信息
    
    /* ***** 模块函数 ********* */
    void creat(); //信息录入
    void modify(); //信息修改
    void ddelete(); //信息删除
    void countStatics(); //统计分析
    void ssort(); //信息排序
    
    /* ****** 信息录入、修改、删除 ********* */
    struct student* creatStudent(); //录入学生基本信息
    struct subject* creatSubject(); //录入课程信息
    struct stscore* creatSubScore(); //录入课程成绩
    struct cominfo* creatAwdPunScore(); //录入综合信息
    struct stCondSc* creatConductScore(); //录入学生品行成绩信息
    struct student* insertStudent(struct student *st); //添加学生基本信息
    struct subject* insertSubject(struct subject *head); //添加课程基本信息
    
    struct student * modifyStudent(); //修改学生基本信息
    struct subject * modifySubject(); //修改课程信息
    struct stscore * modifySubScore(); //修改课程成绩信息
    struct cominfo * modifyAwdPunScore(); //修改奖惩信息
    struct stCondSc * modifyConductScore(); //修改品行成绩信息
    
    void deleteStudent(); //删除学生基本信息
    void deleteSubject(); //删除课程信息
    void deleteStScore(); //删除课程成绩信息
    void deleteStCondSc(); //删除品行成绩信息
    void deleteCominfo(); //删除综合信息
    
    /* ******* 输出查看 *************** */
    void output(); //输出信息
    void outputStudent(); //输出学生基本信息
    void outputSubject(); //输出课程信息
    void outputStScore(); //输出课程成绩
    void outputStCondSc(); //输出学生品行分
    void outputCominfo(); //输出学生综合信息
    
    /* ***** 统计分析 ********* */
    void countSubScore(); //某门课程按分数段成绩统计
    void countAveScore(); //业务课程平均分按分数段统计
    void countStScore(); //统计任意一名同学每门功课的班级排名以及业务课成绩总体排名
    void countDorRank(); //以宿舍为单位进行成绩统计分析
    void countFail(); //分学期统计挂科
    void countChange(); //以业务课班级排名为依据分学期对比分
    void schoshipAsse(); //奖学金评定
    
    /* ****** 排序 ********* */
    void subStScoreSort(); //按课程成绩(高->低)对学生排序
    void failStcntSort(); //按挂科门次(高->低)对学生排序
    void failSubSort(); //按不及格学生数对课程进行由高到低排序
    void dorScoreSort(); //以宿舍为单位按成绩由高到低进行排序
    void awdStSort(); //根据奖励对学生进行由高到低排序
    void punStScore(); //根据惩罚情况对学生由低到高排序
    
    void fprintfStudent(struct student *head);//将学生信息写入文件
    struct student* loadStudent();//从文件中读取学生信息
    void fprintfsubject(struct subject *head);//将课程信息写入文件
    struct subject* loadSubject();//从文件中读取课程信息
    
    //主函数
    int main()
    {
        int choice, n, y = 1;
        char admname[20]="1", password[16]="1"; //用户名,密码
        char an[20], pw[16];
        char c;
        int i;
    
        while (y)
        {
            system("cls");
            printf("\n\n\n\n\n\n\n");
            printf("             ╔*☆***◎***◇***☆*** 欢迎光临 ***☆***◇***◎***☆*╗\n");
            printf("         *********************** 班主任管家系统 ************************\n\n");
            printf("\n\n");
            printf("                      ============1-用户登录===========\n");
            printf("                      ============0-退出系统===========\n");
            printf("       请输入您的选择:");
            scanf("%d", &n);
            printf("\n");
            getchar();
            switch (n)
            {
                case 0: y = 0; break;
                case 1:{
                    printf("       请输入您的用户名:");
                    scanf("%s", an);
                    printf("\n");
                    printf("       请输入您的密码:");
                    i = 0;
                    do
                    {
                        c = getch();
                        if (c == '\b')
                        {
                            printf("\b");
                            putchar('\0');
                            i--;
                            printf("\b");
                        }
                        else if (c != '\r')
                        {
                            printf("*");
                            pw[i] = c;
                            i++;
                        }
                    }while (c != '\r');
                    pw[i] = '\0';
                    printf("\n\n");
                    if (!(strcmp(admname,an)==0 && strcmp(password,pw)==0))
                    {
                        printf("           验证失败,请重新输入!\n");
                        getchar();
                        getchar();
                    }
                    else
                    {
                        printf("             验证通过!请按Enter键进入!\n");
                        getchar();
                        getchar();
                        int x = 1;
                        while (x)
                        {
                            system("cls");
                            printf("                             ------------------\n");
                            printf("                              *班主任管家系统*\n");
                            printf("                             ------------------\n\n");
                            printf("               **********************************************\n\n");
                            printf("               **********************************************\n\n");
                            printf("               || 1-信息录入                   2-信息修改  ||\n\n");
                            printf("               || 3-信息查看                   4-信息排序  ||\n\n");
                            printf("               || 5-统计分析                   6-奖学金评定||\n\n");
                            printf("               || 7-信息删除                   0-退出系统  ||\n\n");
                            printf("               **********************************************\n\n");
                            printf("               **********************************************\n\n");
                            printf("请输入所选择的序号:");
                            scanf("%d",&choice);
                            system("cls");
                            switch (choice)
                            {
                                case 0: x = 0; break;
                                case 1: creat(); break;
                                case 2: modify(); break;
                                case 3: output(); break;
                                case 4: ssort(); break;
                                case 5: countStatics(); break;
                                case 6: schoshipAsse(); getchar(); getchar(); break;
                                case 7: ddelete(); break;
                                default :
                                    printf("               输入错误,请重新输入!\n");
                                    getchar();
                                    break;
                            }//switch
                        }//while(x)
                    }//else
                }//case 1
                break;
                default :
                    printf("               输入错误,请重新输入!\n");
                    getchar();
                    break;
            }//switch(n)
        }//while(y)
        return 0;
    }//main
    
    //信息录入
    void creat()
    {
        st = (struct student *)malloc(sizeof(struct student));
        sub = (struct subject *)malloc(sizeof(struct subject));
        stsc = (struct stscore *)malloc(sizeof(struct stscore));
        coin = (struct cominfo *)malloc(sizeof(struct cominfo));
        stcosc = (struct stCondSc *)malloc(sizeof(struct stCondSc));
    
        int choice, y = 1;
    
        while (y)
        {
            system("cls");
            printf("                             ------------------\n");
            printf("                              *班主任管家系统*\n");
            printf("                                 *信息录入*\n");
            printf("                             ------------------\n\n");
            printf("               ***********************************************\n\n");
            printf("               ***********************************************\n\n");
            printf("               || 1-学生基本信息录入      2-课程信息录入    ||\n\n");
            printf("               || 3-课程成绩录入          4-综合信息录入    ||\n\n");
            printf("               || 5-品行成绩录入          6-添加学生基本信息||\n\n");
            printf("               || 7-添加课程信息          0-退出系统        ||\n\n");
            printf("               ***********************************************\n\n");
            printf("               ***********************************************\n\n");
            printf("请输入所选择的序号:");
            scanf("%d",&choice);
            system("cls");
            switch (choice)
            {
                case 0: y = 0; break;
                case 1: st = creatStudent();  getchar(); break;
                case 2: sub = creatSubject(); getchar(); break;
                case 3: stsc = creatSubScore(); getchar(); break;
                case 4: coin =  creatAwdPunScore(); getchar(); break;
                case 5: stcosc = creatConductScore(); getchar(); break;
                case 6:
                    st = loadStudent();
                    st = insertStudent(st);
                    getchar();
                    break;
                case 7:
                    sub = loadSubject();
                    sub = insertSubject(sub);
                    getchar();
                    break;
                default:
                    printf("               输入错误,请重新输入!\n");
                    getchar();
                    break;
            }//switch(choice)
            getchar();
        }//while(y)
    }//creat
    
    //信息修改
    void modify()
    {
        int choice, y = 1;
    
        while (y)
        {
            system("cls");
            printf("                             ------------------\n");
            printf("                              *班主任管家系统*\n");
            printf("                                 *信息修改*\n");
            printf("                             ------------------\n\n");
            printf("               **********************************************\n\n");
            printf("               **********************************************\n\n");
            printf("               || 1-学生基本信息修改        2-课程信息修改 ||\n\n");
            printf("               || 3-课程成绩修改            4-品行成绩修改 ||\n\n");
            printf("               || 5-奖惩信息修改            0-退出系统     ||\n\n");
            printf("               **********************************************\n\n");
            printf("               **********************************************\n\n");
            printf("请输入所选择的序号:");
            scanf("%d",&choice);
            system("cls");
            switch (choice)
            {
                case 0: y = 0; break;
                case 1: st = modifyStudent(); getchar(); break;
                case 2: sub = modifySubject(); getchar(); break;
                case 3: stsc = modifySubScore(); getchar(); break;
                case 4: stcosc = modifyConductScore(); getchar(); break;
                case 5: coin = modifyAwdPunScore(); getchar(); break;
                default:
                    printf("               输入错误,请重新输入!\n");
                    getchar();
                    break;
            }//switch(choice)
            getchar();
        }//while(y)
    }//modify
    
    //信息输出
    void output()
    {
        int choice, y = 1;
    
        while (y)
        {
            system("cls");
            printf("                             ------------------\n");
            printf("                              *班主任管家系统*\n");
            printf("                                 *信息查看*\n");
            printf("                             ------------------\n\n");
            printf("               **********************************************\n\n");
            printf("               **********************************************\n\n");
            printf("               || 1-查看学生基本信息        2-查看课程信息 ||\n\n");
            printf("               || 3-查看学生品行成绩        4-查看课程成绩 ||\n\n");
            printf("               || 5-查看学生综合信息        0-退出系统     ||\n\n");
            printf("               **********************************************\n\n");
            printf("               **********************************************\n\n");
            printf("请输入所选择的序号:");
            scanf("%d",&choice);
            system("cls");
            switch (choice)
            {
                case 0: y = 0; break;
                case 1: outputStudent(); getchar(); break;
                case 2: outputSubject(); getchar(); break;
                case 3: outputStCondSc(); getchar(); break;
                case 4: outputStScore(); getchar(); break;
                case 5: outputCominfo(); getchar(); break;
                default:
                    printf("               输入错误,请重新输入!\n");
                    getchar();
                    break;
            }//switch(choice)
            getchar();
        }//while(y))
    }//output
    
    //统计分析
    void countStatics()
    {
        int choice, y = 1;
    
        while (y)
        {
            system("cls");
            printf("                             ------------------\n");
            printf("                              *班主任管家系统*\n");
            printf("                                 *统计分析*\n");
            printf("                             ------------------\n\n");
            printf("               ****************************************************\n\n");
            printf("               ****************************************************\n\n");
            printf("               || 1-课程分数段统计        2-课程平均分分数段统计 ||\n\n");
            printf("               || 3-学生个人排名统计      4-宿舍成绩统计分析     ||\n\n");
            printf("               || 5-分学期挂科统计        6-学生进退分析         ||\n\n");
            printf("               || 0-退出系统                                     ||\n\n");
            printf("               ****************************************************\n\n");
            printf("               ****************************************************\n\n");
            printf("请输入所选择的序号:");
            scanf("%d",&choice);
            system("cls");
            switch (choice)
            {
                case 0: y = 0; break;
                case 1: countSubScore(); getchar(); break;
                case 2: countAveScore(); getchar(); break;
                case 3: countStScore(); getchar(); break;
                case 4: countDorRank(); getchar(); break;
                case 5: countFail(); getchar(); break;
                case 6: countChange(); getchar(); break;
                default:
                    printf("               输入错误,请重新输入!\n");
                    getchar();
                    break;
            }//switch(choice)
            getchar();
        }//while(y)
    }
    
    //信息排序
    void ssort()
    {
        int choice, y = 1;
    
        while (y)
        {
            system("cls");
            printf("                             ------------------\n");
            printf("                              *班主任管家系统*\n");
            printf("                                 *信息排序*\n");
            printf("                             ------------------\n\n");
            printf("               **************************************************\n\n");
            printf("               **************************************************\n\n");
            printf("               || 1-学生课程成绩排序        2-学生挂科门次排序 ||\n\n");
            printf("               || 3-课程挂科人次排序        4-宿舍成绩排序     ||\n\n");
            printf("               || 5-学生奖励情况排序        6-学生惩处情况排序 ||\n\n");
            printf("               || 0-退出系统                                   ||\n\n");
            printf("               **************************************************\n\n");
            printf("               **************************************************\n\n");
            printf("请输入所选择的序号:");
            scanf("%d",&choice);
            getchar();
            system("cls");
            switch (choice)
            {
                case 0:  y = 0; break;
                case 1: subStScoreSort(); getchar(); break;
                case 2: failStcntSort(); getchar(); break;
                case 3: failSubSort(); getchar(); break;
                case 4: dorScoreSort(); getchar(); break;
                case 5: awdStSort(); getchar(); break;
                case 6: punStScore(); getchar(); break;
                default:
                    printf("               输入错误,请重新输入!\n");
                    getchar();
                    break;
            }//switch(choice)
        }//while(y)
    }//ssort
    
    //信息删除
    void ddelete()
    {
        int choice, y = 1;
    
        while (y)
        {
            system("cls");
            printf("                             ------------------\n");
            printf("                              *班主任管家系统*\n");
            printf("                                 *信息删除*\n");
            printf("                             ------------------\n\n");
            printf("               **********************************************\n\n");
            printf("               **********************************************\n\n");
            printf("               || 1-学生基本信息删除        2-课程信息删除 ||\n\n");
            printf("               || 3-课程成绩删除            4-品行成绩删除 ||\n\n");
            printf("               || 5-综合信息删除            0-退出系统     ||\n\n");
            printf("               **********************************************\n\n");
            printf("               **********************************************\n\n");
            printf("请输入所选择的序号:");
            scanf("%d",&choice);
            system("cls");
            switch (choice)
            {
                case 0: y = 0; break;
                case 1: deleteStudent(); getchar(); break;
                case 2: deleteSubject(); getchar(); break;
                case 3: deleteStScore(); getchar(); break;
                case 4: deleteStCondSc(); getchar(); break;
                case 5: deleteCominfo(); getchar(); break;
                default:
                    printf("               输入错误,请重新输入!\n");
                    getchar();
                    break;
            }//switch(choice)
            getchar();
        }//while(y)
    }//modify
    
    //判断学号是否已存在
    //存在返回1,不存在返回0
    int isNumExist(struct student *head, char *num)
    {
        struct student *q = head;
        while (q != NULL)
        {
            if (strcmp(q ->stnum, num) == 0)
                return 1;
            q = q ->next;
        }
        return 0;
    }
    
    //将学生信息写入文件
    void fprintfStudent(struct student *head)
    {
        FILE *fp;
        struct student *p;
        if ((fp = fopen("student.txt", "w")) == NULL)
        {
            printf("Can't open the file!\n");
            return ;
        }
        p = head;
        while (p != NULL)
        {
            fprintf(fp, "%s\t%s\t%s\t%d\t%s\n", p ->stnum, p ->stname, p ->stsex, p ->stage, p ->dornum);
            p = p ->next;
        }
        fclose(fp);
    }//fprintfStudent
    
    //从文件中读取学生信息
    struct student* loadStudent()
    {
        FILE *fp;
        struct student *head, *tail, *p;
    
        head = tail = NULL;
        if ((fp = fopen("student.txt", "r")) == NULL)
        {
            printf("Can't open the file!\n");
            exit(0);
        }
        while (!feof(fp))
        {
            p = (struct student *)malloc(sizeof(struct student));
            fscanf(fp, "%s\t%s\t%s\t%d\t%s\n",  p ->stnum, p ->stname, p ->stsex, &p ->stage, p ->dornum);
            if (head == NULL)
                head = p;
            else
                tail ->next = p;
            tail = p;
        }
        tail ->next = NULL;
        fclose(fp);
        return head;
    }//loadStudent
    
    //录入学生基本信息
    struct student* creatStudent()
    {
        struct student *head, *tail, *p;
        head = (struct student *)malloc(sizeof(struct student));
        int age, key, y = 1;
        char num[12], sex[6], dn[10], name[20];
        char kk[3] = "0";
        char ss1[5] = "男", ss2[5] = "女";
    
        head = tail = NULL;
        printf("请输入学生信息,以学号0为结束!\n");
        while (y)
        {
            printf("\n");
            do
            {
                printf("请输入学生学号:");
                scanf("%s", num);
                if (strlen(num) != 10 && strcmp(kk, num) != 0)
                {
                    printf("学号格式输入错误,请重新输入!\n");
                    key = 1;
                }
                else
                {
                    key = isNumExist(head, num);
                    if (key == 1)
                        printf("该学号已存在,请重新输入!\n");
                    if (strcmp(kk, num) == 0)
                        y = 0;
                }
            }while (key == 1);
            if (y != 0)
            {
                printf("请输入学生姓名:");
                scanf("%s", name);
                do
                {
                    key = 1;
                    printf("请输入学生性别:");
                    scanf("%s", sex);
                    if (strcmp(sex, ss1)==0 || strcmp(sex, ss2)==0)
                        key = 0;
                    else
                        printf("性别输入错误,请重新输入!\n");
                }while(key == 1);
                printf("请输入学生年龄:");
                scanf("%d", &age);
                //getchar();
                printf("请输入学生宿舍号:");
                scanf("%s", dn);
    
                printf("是否要存储该学生信息?\n");
                printf("  1-确定   0-取消\n");
                int k;
                scanf("%d", &k);
                if (k == 1)
                {
                    p = (struct student *)malloc(sizeof(struct student));
                    strcpy(p ->stname, name);
                    strcpy(p ->stnum, num);
                    strcpy(p ->stsex, sex);
                    strcpy(p ->dornum, dn);
                    p ->stage = age;
                    p ->next = NULL;
                    if(head == NULL)
                        head = p;
                    else
                        tail ->next = p;
                    tail = p;
                }//if
            }//if
        }//while(y)
        printf("是否要覆盖原有信息,并将其存入文件?");
        printf("  1-确认   0-取消\n");
        printf("请选择:");
        scanf("%d", &y);
        if (y)
        {
            fprintfStudent(head);
            printf("\n录入学生基本信息成功!\n");
        }
        printf("\n **按Enter返回!");
        return head;
    }//creatStudent
    
    //添加学生基本信息
    struct student* insertStudent(struct student *head)
    {
        struct student *tail, *p;
        int age, key, y = 1;
        char num[12], sex[6], dn[6], name[20];
        char kk[3] = "0";
    
        tail = head;
        while (tail!=NULL && tail ->next!=NULL)
        {
            tail = tail ->next;
        }
    
        printf("请输入学生信息,以学号0为结束!\n");
        while (y)
        {
            printf("\n");
            do
            {
                printf("请输入学生学号:");
                scanf("%s", num);
                if (strlen(num) != 10 && strcmp(kk, num) != 0)
                {
                    printf("学号格式输入错误,请重新输入!\n");
                    key = 1;
                }
                else
                {
                    key = isNumExist(head, num);
                    if (key == 1)
                        printf("该学号已存在,请重新输入!\n");
                    if (strcmp(kk, num) == 0)
                        y = 0;
                }
            }while (key == 1);
            if (y != 0)
            {
                printf("请输入学生姓名:");
                scanf("%s", name);
                printf("请输入学生性别:");
                scanf("%s", sex);
                printf("请输入学生年龄:");
                scanf("%d", &age);
                printf("请输入学生宿舍号:");
                scanf("%s", dn);
    
                printf("是否要存储该学生信息?\n");
                printf("  1-确定   0-取消\n");
                int k;
                scanf("%d", &k);
                if (k == 1)
                {
                    p = (struct student *)malloc(sizeof(struct student));
                    strcpy(p ->stname, name);
                    strcpy(p ->stnum, num);
                    strcpy(p ->stsex, sex);
                    strcpy(p ->dornum, dn);
                    p ->stage = age;
                    p ->next = NULL;
                    if(head == NULL)
                        head = p;
                    else
                        tail ->next = p;
                    tail = p;
                }//if
            }//if
        }//while(y)
        fprintfStudent(head);
        printf("添加学生基本信息成功!\n");
        printf("\n **按Enter返回!");
        return head;
    }//insertStudent
    
    //判断学号是否已存在
    //存在返回1,不存在返回0
    int isNumExist(struct subject *head, char *num)
    {
        struct subject *q = head;
        while (q != NULL)
        {
            if (strcmp(q ->subNum, num) == 0)
                return 1;
            q = q ->next;
        }
        return 0;
    }//isNumExist
    
    //将课程信息写入文件
    void fprintfsubject(struct subject *head)
    {
        FILE *fp;
        struct subject *p;
        if ((fp = fopen("subject.txt", "w")) == NULL)
        {
            printf("Can't open the file!\n");
            return ;
        }
        p = head;
        while (p != NULL)
        {
            fprintf(fp, "%s\t%s\t%s\t%g\t%d\n", p ->subNum, p ->subName, p ->cate, p ->credit, p ->term);
            p = p ->next;
        }
        fclose(fp);
    }//fprintfsubject
    
    //从文件中读取课程信息
    struct subject* loadSubject()
    {
        FILE *fp;
        struct subject *head, *tail, *p;
    
        head = tail = NULL;
        if ((fp = fopen("subject.txt", "r")) == NULL)
        {
            printf("Can't open the file!\n");
            exit(0);
        }
        while (!feof(fp))
        {
            p = (struct subject *)malloc(sizeof(struct subject));
            fscanf(fp, "%s\t%s\t%s\t%g\t%d\n",  p ->subNum, p ->subName, p ->cate, &p ->credit, &p ->term);
            if (head == NULL)
                head = p;
            else
                tail ->next = p;
            tail = p;
        }
        tail ->next = NULL;
        fclose(fp);
        return head;
    }//loadSubject
    
    //录入课程信息
    struct subject* creatSubject()
    {
        struct subject *head, *tail, *p;
        head = (struct subject *)malloc(sizeof(struct subject));
        int key, y = 1;
        char num[12], cate[6], name[20];
        int term;
        float credit;
        char kk[3] = "0";
    
        head = tail = NULL;
        printf("请输入课程信息,以编号0为结束!\n");
        while (y)
        {
            printf("\n");
            do
            {
                printf("请输入课程编号:");
                scanf("%s", num);
                key = isNumExist(head, num);
                if (key == 1)
                    printf("该编号已存在,请重新输入!\n");
                if (strcmp(kk, num) == 0)
                    y = 0;
            }while (key == 1);
            if (y != 0)
            {
                printf("请输入课程名称:");
                scanf("%s", name);
                printf("请输入课程类别:");
                scanf("%s", cate);
                printf("请输入课程学分:");
                scanf("%f", &credit);
                printf("请输入课程所在学期:");
                scanf("%d", &term);
    
                printf("是否要存储该课程信息?\n");
                printf("  1-确定   0-取消\n");
                int k;
                scanf("%d", &k);
                if (k == 1)
                {
                    p = (struct subject *)malloc(sizeof(struct subject));
                    strcpy(p ->subName , name);
                    strcpy(p ->subNum, num);
                    strcpy(p ->cate, cate);
                    p ->term = term;
                    p ->credit = credit;
                    p ->next = NULL;
                    if(head == NULL)
                        head = p;
                    else
                        tail ->next = p;
                    tail = p;
                }//if
            }//if
        }//while(y)
        printf("是否要覆盖原有信息,并将其存入文件?");
        printf("  1-确认   0-取消\n");
        printf("请选择:");
        scanf("%d", &y);
        if (y)
        {
            fprintfsubject(head);
            printf("\n录入课程信息成功!\n");
        }
        printf("\n **按Enter返回!");
        return head;
    }//creatsubject
    
    //添加课程信息
    struct subject* insertSubject(struct subject *head)
    {
        struct subject *tail, *p;
        int key, y = 1;
        char num[12], cate[6], name[20];
        int term;
        float credit;
        char kk[3] = "0";
    
        tail = head;
        while (tail!=NULL && tail ->next!=NULL)
        {
            tail = tail ->next;
        }
    
        printf("请输入课程信息,以编号0为结束!\n");
        while (y)
        {
            printf("\n");
            do
            {
                printf("请输入课程编号:");
                scanf("%s", num);
                key = isNumExist(head, num);
                if (key == 1)
                    printf("该编号已存在,请重新输入!\n");
                if (strcmp(kk, num) == 0)
                    y = 0;
            }while (key == 1);
            if (y != 0)
            {
                printf("请输入课程名称:");
                scanf("%s", name);
                printf("请输入课程类别:");
                scanf("%s", cate);
                printf("请输入课程学分:");
                scanf("%f", &credit);
                printf("请输入课程所在学期:");
                scanf("%d", &term);
    
                printf("是否要存储该课程信息?\n");
                printf("  1-确定   0-取消\n");
                int k;
                scanf("%d", &k);
                if (k == 1)
                {
                    p = (struct subject *)malloc(sizeof(struct subject));
                    strcpy(p ->subName , name);
                    strcpy(p ->subNum, num);
                    strcpy(p ->cate, cate);
                    p ->term = term;
                    p ->credit = credit;
                    p ->next = NULL;
                    if(head == NULL)
                        head = p;
                    else
                        tail ->next = p;
                    tail = p;
                }//if
            }//if
        }//while(y)
        fprintfsubject(head);
        printf("添加课程信息成功!\n");
        printf("\n **按Enter返回!");
        return head;
    }//insertStudent
    
    //判断学号与成绩是否已存在
    //存在返回1,不存在返回0
    int isNumExist(struct stscore *a, char *stnum, int n)
    {
         for (int i = 0; i < n; i++)
        {
            if (strcmp(a[i].stnum, stnum)==0)
                return 1;
        }
        return 0;
    }//isNumExist
    
    //将课程成绩写入文件
    void fprintfstscore(struct stscore *head, char *subname)
    {
        FILE *fp;
        struct stscore *p;
        if ((fp = fopen(subname, "w")) == NULL)
        {
            printf("Can't open the file!\n");
            return ;
        }
        p = head;
        while (p != NULL)
        {
            fprintf(fp, "%s\t%s\t%d\t%s\n", p ->stnum, p ->subNum, p ->mark, p ->repair);
            p = p ->next;
        }
        fclose(fp);
    }//fprintfstscore
    
    //录入课程成绩
    struct stscore * creatSubScore()
    {
        struct subject *head_sub, *r, *a[20];
        struct stscore *head_sc, *p, *tail;
        struct student *head_st, *q;
        char term[3];
        char subname[20];
        int cnt;
        int mark, k, t;
        head_sc = (struct stscore *)malloc(sizeof(struct stscore));
        head_st = loadStudent();
        r = head_sub = loadSubject();
    
        tail = head_sc;
        printf("请输入学期:");
        scanf("%s", term);
        t = 0 + term[0] - '0';
        printf("         第%d学期课程\n", t);
        printf("   =========================\n");
        cnt = 1;
        while (r)
        {
            if (r ->term == t)
            {
                a[cnt] = r;
                printf("     %d -- %s\n", cnt++, r ->subName);
            }
            r = r ->next;
        }
        printf("     请选择:");
        scanf("%d", &t);
        strcpy(subname, a[t] ->subName);
        strcat(subname, "_");
        strcat(subname, term);
        strcat(subname, ".txt");
    
        system("cls");
        printf("     %s 课程成绩录入\n", a[t] ->subName);
        printf("   =======================\n");
        printf("请输入对应学号的成绩\n");
        printf("     学  号         成绩\n");
        q = head_st;
        while (q)
        {
            p = (struct stscore *)malloc(sizeof(struct stscore));
            tail ->next = p;
            tail = p;
            printf("   %s  :    ", q ->stnum);
            strcpy(p ->stnum ,q ->stnum);
            strcpy(p ->subNum, a[t] ->subNum);
            do
            {
                k = 1;
                scanf("%d", &mark);
                if (mark < 0 || mark > 100)
                {
                    printf("成绩输入错误,请重新输入:");
                    k = 0;
                }
            }while (k == 0);
            p ->mark = mark;
            if (p ->mark < 60)
                strcpy(p ->repair, "Y");
            else
                strcpy(p ->repair, "N");
            q = q ->next;
        }//while
        tail ->next = NULL;
    
        fprintfstscore(head_sc ->next, subname);
        printf("\n录入课程成绩成功!\n");
        printf("\n **按Enter返回!");
        return head_sc;
    }//creatSubScore
    
    //判断学号是否已存在
    //存在返回1,不存在返回0
    int isNumExist(struct stCondSc *head, char *stNum)
    {
        struct stCondSc *q = head;
        while (q != NULL)
        {
            if (strcmp(q ->stnum, stNum) == 0)
                return 1;
            q = q ->next;
        }
        return 0;
    }//isNumExist
    
    //将学生品行成绩信息写入文件
    void fprintfstCondSc(struct stCondSc *head)
    {
        FILE *fp;
        struct stCondSc *p;
        if ((fp = fopen("stCondSc.txt", "w")) == NULL)
        {
            printf("Can't open the file!\n");
            return ;
        }
        p = head;
        while (p != NULL)
        {
            fprintf(fp, "%s\t%d\t%d\t%d\t%d\n", p ->stnum, p ->coumark, p ->headmark, p ->classsmark, p ->conductmark);
            p = p ->next;
        }
        fclose(fp);
    }//fprintfstCondSc
    
    //录入学生品行成绩信息
    struct stCondSc* creatConductScore()
    {
        struct stCondSc *head, *tail, *p;
        struct student *head_st, *q;
        int mark, k;
        head = (struct stCondSc*)malloc(sizeof(struct stCondSc));
        q = head_st = loadStudent();
        tail = head;
    
        printf("请输入学生品行成绩信息\n");
        while (q)
        {
            p = (struct stCondSc *)malloc(sizeof(struct stCondSc));
            tail ->next = p;
            tail = p;
            printf("学号:%s\n", q ->stnum);
            strcpy(p ->stnum ,q ->stnum);
            printf("辅导员打分:");
            do
            {
                k = 1;
                scanf("%d", &mark);
                if (mark < 0 || mark > 100)
                {
                    printf("成绩输入错误,请重新输入:");
                    k = 0;
                }
            }while (k == 0);
            p ->coumark = mark;
    
            printf("班主任打分:");
            do
            {
                k = 1;
                scanf("%d", &mark);
                if (mark < -1 || mark > 100)
                {
                    printf("成绩输入错误,请重新输入:");
                    k = 0;
                }
            }while (k == 0);
            p ->headmark = mark;
    
            printf("班级打分:");
            do
            {
                k = 1;
                scanf("%d", &mark);
                if (mark < 0 || mark > 100)
                {
                    printf("成绩输入错误,请重新输入:");
                    k = 0;
                }
            }while (k == 0);
            p ->classsmark = mark;
            p ->conductmark = p ->classsmark + p ->coumark + p ->headmark;
            printf("\n");
            q = q ->next;
        }//while
        fprintfstCondSc(head ->next);
        printf("\n录入品行成绩成功!\n");
        printf("\n **按Enter返回!");
        return head;
    }//creatConductScore
    
    //判断学号是否已存在
    //存在返回1,不存在返回0
    int isNumExist(struct cominfo *head, char *stNum)
    {
        struct cominfo *q = head;
        while (q != NULL)
        {
            if (strcmp(q ->stnum, stNum) == 0)
                return 1;
            q = q ->next;
        }
        return 0;
    }//isNumExist
    
    //将学生综合信息写入文件
    void fprintfStCominfo(struct cominfo *head)
    {
        FILE *fp;
        struct cominfo *p;
        if ((fp = fopen("cominfo.txt", "w")) == NULL)
        {
            printf("Can't open the file!\n");
            return ;
        }
        p = head;
        while (p != NULL)
        {
            fprintf(fp, "%s\t%s\t%d\n", p ->stnum, p ->stname, p ->getcredit);
            fprintf(fp, "%s\t%d-%d-%d\t%d\n", p ->awdlev, p ->ayear, p ->amon, p ->aday, p ->amark);
            fprintf(fp, "%s\t%d-%d-%d\t%d\n", p ->puncate, p ->pyear, p ->pmon, p ->pday, p ->pmark);
            p = p ->next;
        }
        fclose(fp);
    } //fprintfAwdPunScore
    
    //录入学生综合信息
    struct cominfo* creatAwdPunScore()
    {
        struct cominfo *head, *tail, *p;
        struct student *head_st, *q;
        int t;
        head = (struct cominfo *)malloc(sizeof(struct cominfo));
        tail = head;
        q = head_st = loadStudent();
    
        printf("请输入学生综合信息\n");
        while (q)
        {
            p = (struct cominfo *)malloc(sizeof(struct cominfo));
            tail ->next = p;
            tail = p;
            printf("学号:%s\n", q ->stnum);
            printf("姓名:%s\n", q ->stname);
            strcpy(p ->stnum, q ->stnum);
            strcpy(p ->stname, q ->stname);
            printf("是否有奖励记录:");
            printf("1 - 是   0 - 否\n");
            scanf("%d", &t);
            if (t)
            {
                printf("请输入奖励类别:");
                scanf("%s", p ->awdlev);
                printf("请输入获奖时间(年 月 日):");
                scanf("%d %d %d", &p ->ayear, &p ->amon, &p ->aday);
                printf("请输入奖励分值:");
                scanf("%d", &p ->amark);
            }
            else
            {
                strcpy(p ->awdlev, "无");
                p ->aday = 0;
                p ->amon = 0;
                p ->aday = 0;
                p ->amark = 0;
            }
            printf("是否有惩处记录:");
            printf("1 - 是   0 - 否\n");
            scanf("%d", &t);
            if(t)
            {
                printf("请输入惩处类别:");
                scanf("%s", p ->puncate);
                printf("请输入惩处时间:");
                scanf("%d %d %d", &p ->pyear, &p ->amon, &p ->pday);
                printf("请输入惩罚分值:");
                scanf("%d", &p ->pmark);
            }
            else
            {
                strcpy(p ->puncate, "无");
                p ->pyear = 0;
                p ->pmon = 0;
                p ->pday = 0;
                p ->pmark = 0;
            }
            printf("\n");
            q = q ->next;
        }//while
    
        fprintfStCominfo(head ->next);
        printf("录入学生综合信息成功!\n");
        printf("\n **按Enter返回!");
        return head;
    }//creatAwdPunScore
    
    //修改学生基本信息
    struct student* modifyStudent()
    {
        char stnum[15];
        char sex[6];
        struct student* head, *p;
        int key = 1, t;
        char ss1[5] = "男", ss2[5] = "女";
    
        printf("请输入要修改学生的学号:");
        do
        {
            scanf("%s", stnum);
            if (strlen(stnum) != 10)
            {
                printf("学号格式输入错误,请重新输入!\n");
                printf("请输入学号:");
            }
            else
                key = 0;
        }while (key == 1);
    
        head = loadStudent();
        p = head;
        while (p!=NULL && strcmp(p ->stnum,stnum)!=0)
        {
            p = p ->next;
        }
        if (p == NULL)
            printf("未找到,修改失败!\n");
        else
        {
            printf("请输入修改后的信息:\n");
            printf("请输入姓名:");
            scanf("%s", p ->stname);
            do
            {
                key = 1;
                printf("请输入性别:");
                scanf("%s", sex);
                if (strcmp(sex, ss1)==0 || strcmp(sex, ss2)==0)
                    key = 0;
                else
                    printf("性别输入错误,请重新输入!\n");
            }while(key == 1);
            strcpy(p ->stsex, sex);
            printf("请输入年龄:");
            scanf("%d", &p ->stage);
            printf("请输入宿舍号:");
            scanf("%s", p ->dornum);
            printf(" *确认修改?\n");
            printf("  1-确认  0-取消\n  ");
            scanf("%d", &t);
            if (t)
            {
                fprintfStudent(head);
                printf("修改成功!\n");
            }
        }//else
        printf("\n **按Enter返回!");
        return head;
    }//modifyStudent
    
    //修改课程信息
    struct subject * modifySubject()
    {
        struct subject *head, *p;
        char subnum[20];
    
        printf("请输入要修改课程的课程号:");
        scanf("%s", subnum);
    
        head = loadSubject();
        p = head;
        while (p!=NULL && strcmp(p ->subNum,subnum)!=0)
        {
            p = p ->next;
        }
        if (p != NULL)
        {
            printf("请输入修改后的课程信息:\n");
            printf("请输入课程名称:");
            scanf("%s", p ->subName);
            printf("请输入课程类别:");
            scanf("%s", p ->cate);
            printf("请输入课程学分:");
            scanf("%f", &p ->credit);
            printf("请输入课程所在学期:");
            scanf("%d", &p ->term);
            fprintfsubject(head);
            printf("修改成功!\n");
        }//if
        else
            printf("未找到,修改失败!\n");
        printf("\n **按Enter返回!");
        return head;
    }//modifySubject
    
    //从文件中读取课程成绩
    struct stscore * loadStscore(char *modname)
    {
        FILE *fp;
        struct stscore *head, *tail, *p;
    
        head = tail = NULL;
        if ((fp = fopen(modname, "r")) == NULL)
        {
            printf("Can't open the file!\n");
            exit(0);
        }
        while (!feof(fp))
        {
            p = (struct stscore *)malloc(sizeof(struct subject));
            fscanf(fp, "%s\t%s\t%d\t%s\n",  p ->stnum, p ->subNum, &p ->mark, p ->repair);
            if (head == NULL)
                head = p;
            else
                tail ->next = p;
            tail = p;
        }//while
        tail ->next = NULL;
        fclose(fp);
        return head;
    }//loadSubject
    
    //判断学号是否存在
    int isNumExist(struct stscore *head, char *num)
    {
        struct stscore *q = head;
        while (q != NULL)
        {
            if (strcmp(q ->stnum , num) == 0)
                return 1;
            q = q ->next;
        }
        return 0;
    }//isNumExist
    
    //修改课程成绩信息
    struct stscore * modifySubScore()
    {
        struct stscore *head, *p;
        struct subject *head_sub, *r, *a[10];
        char subname[20], stnum[15];
        int mark;
        int t, cnt;
        char term[3];
    
        printf("请输入学期:");
        scanf("%s", term);
        t = 0 + term[0] - '0';
        r = head_sub = loadSubject();
        printf("         第%d学期课程\n", t);
        printf("   =========================\n");
        cnt = 1;
        while (r)
        {
            if (r ->term == t)
            {
                a[cnt] = r;
                printf("     %d -- %s\n", cnt++, r ->subName);
            }
            r = r ->next;
        }
        printf("     请选择:");
        scanf("%d", &t);
        strcpy(subname, a[t] ->subName);
        strcat(subname, "_");
        strcat(subname, term);
        strcat(subname, ".txt");
    
        system("cls");
        printf("请输入学号:");
        scanf("%s", stnum);
        head = loadStscore(subname);
        p = head;
        while (p!=NULL && strcmp(p ->stnum, stnum) != 0)
        {
            p = p ->next;
        }
        if (p != NULL)
        {
            printf("请输入修改后的信息:\n");
            printf("请输入成绩:");
            scanf("%d", &mark);
            while (mark>100 || mark < 0)
            {
                printf("成绩格式错误,请重新输入!\n");
                printf("请输入成绩:");
                scanf("%d", &mark);
            }
            p ->mark = mark;
            if (p ->mark >= 60)
                strcpy(p ->repair, "N");
            else
                strcpy(p ->repair, "Y");
            fprintfstscore(head, subname);
            printf("\n **修改成功!\n");
        }//if
        else
            printf(" **未找到,修改失败!\n");
        printf("\n **按Enter返回!");
        return head;
    }//modifySubScore
    
    //从文件中读入学生品行信息
    struct stCondSc * loadstCondSc()
    {
        FILE *fp;
        struct stCondSc *head, *tail, *p;
    
        head = tail = NULL;
        if ((fp = fopen("stCondSc.txt", "r")) == NULL)
        {
            printf("Can't open the file!\n");
            exit(0);
        }
        while (!feof(fp))
        {
            p = (struct stCondSc *)malloc(sizeof(struct stCondSc));
            fscanf(fp, "%s\t%d\t%d\t%d\t%d\n",  p ->stnum, &p ->coumark, &p ->headmark, &p ->classsmark, &p ->conductmark);
            if (head == NULL)
                head = p;
            else
                tail ->next = p;
            tail = p;
        }
        tail ->next = NULL;
        fclose(fp);
        return head;
    }//loadstCondSc
    
    //修改品行成绩信息
    struct stCondSc * modifyConductScore()
    {
        char stnum[12];
        struct stCondSc *head, *p;
        int key;
    
        printf("请输入要修改学生的学号:");
    
        do
        {
            scanf("%s", stnum);
            if (strlen(stnum) != 10)
            {
                printf("学号格式输入错误,请重新输入!\n");
                printf("请输入学号:");
                key = 1;
            }
            else
                key = 0;
        }while (key == 1);
    
        p = head = loadstCondSc();
        while (p!=NULL && strcmp(p ->stnum,stnum)!=0)
        {
            p = p ->next;
        }
        if (p == NULL)
            printf("未找到,修改失败!\n");
        else
        {
            printf("请输入修改后的信息:\n");
            printf("辅导员打分:");
            scanf("%d", &p ->coumark);
            printf("班主任打分:");
            scanf("%d", &p ->headmark);
            printf("班级打分:");
            scanf("%d", &p ->classsmark);
            p ->conductmark = p ->classsmark + p ->coumark + p ->headmark;
            fprintfstCondSc(head);
            printf("  修改成功!\n");
        }//else
        printf("\n **按Enter返回!\n");
        return head;
    }//modifyConductScore
    
    //从文件中读入学生品行信息
    struct cominfo * loadstCominfo()
    {
        FILE *fp;
        struct cominfo *head, *tail, *p;
    
        head = tail = NULL;
        if ((fp = fopen("cominfo.txt", "r")) == NULL)
        {
            printf("Can't open the file!\n");
            exit(0);
        }
        while (!feof(fp))
        {
            p = (struct cominfo *)malloc(sizeof(struct cominfo));
            fscanf(fp, "%s\t%s\t%d\n", p ->stnum, p ->stname, &p ->getcredit);
            fscanf(fp, "%s\t%d-%d-%d\t%d\n", p ->awdlev, &p ->ayear, &p ->amon, &p ->aday, &p ->amark);
            fscanf(fp, "%s\t%d-%d-%d\t%d\n", p ->puncate, &p ->pyear, &p ->pmon, &p ->pday, &p ->pmark);
    
            if (head == NULL)
                head = p;
            else
                tail ->next = p;
            tail = p;
        }//while
        tail ->next = NULL;
        fclose(fp);
        return head;
    }//loadstCominfo
    
    //修改奖惩信息
    struct cominfo * modifyAwdPunScore()
    {
        char stnum[12];
        struct cominfo *head, *p;
        int key;
    
        printf("请输入要修改学生的学号:");
        do
        {
            scanf("%s", stnum);
            if (strlen(stnum) != 10)
            {
                printf("学号格式输入错误,请重新输入!\n");
                printf("请输入学号:");
                key = 1;
            }
            else
                key = 0;
        }while (key == 1);
    
        p = head = loadstCominfo();
        while (p!=NULL && strcmp(p ->stnum,stnum)!=0)
        {
            p = p ->next;
        }
        if (p == NULL)
            printf("未找到,修改失败!\n");
        else
        {
            printf("请输入修改后的信息:\n");
            printf("是否有奖励记录:");
            printf("1 - 是   0 - 否\n");
            int t;
            scanf("%d", &t);
            if (t)
            {
                printf("请输入奖励类别:");
                scanf("%s", p ->awdlev);
                printf("请输入获奖时间(年 月 日):");
                scanf("%d %d %d", &p ->ayear, &p ->amon, &p ->aday);
                printf("请输入奖励分值:");
                scanf("%d", &p ->amark);
            }//if
            else
            {
                strcpy(p ->awdlev, "无");
                p ->ayear = 0;
                p ->amon = 0;
                p ->aday = 0;
                p ->amark = 0;
            }//else
            printf("是否有惩处记录:");
            printf("1 - 是   0 - 否\n");
            scanf("%d", &t);
            if(t)
            {
                printf("请输入惩处类别:");
                scanf("%s", p ->puncate);
                printf("请输入惩处时间:");
                scanf("%d %d %d", &p ->pyear, &p ->pmon, &p ->pday);
                printf("请输入惩罚分值:");
                scanf("%d", &p ->pmark);
            }//if
            else
            {
                strcpy(p ->puncate, "无");
                p ->pyear = 0;
                p ->pmon = 0;
                p ->pday = 0;
                p ->pmark = 0;
            }//else
            p ->getcredit = p ->amark - p ->pmark;
            fprintfStCominfo(head);
            printf("\n **修改成功,按Enter返回!\n");
        }//else
        return head;
    }//modifyAwdPunScore
    
    //输出学生基本信息
    void outputStudent()
    {
        struct student *head, *p;
        p = head = loadStudent();
        printf("\n\n\t\t \t\t*****学生基本信息*****\n");
        printf("\t\t ==============================================\n");
        printf("\t\t   学  号\t 姓 名\t性别\t年龄\t宿舍号\n");
        printf("\t\t ==============================================\n");
        while (p)
        {
            printf("\t\t %s\t%s\t %s\t %d\t%s\n", p ->stnum, p ->stname, p ->stsex, p ->stage, p ->dornum);
            p = p ->next;
        }
        printf("\t\t ==============================================\n");
        printf("\n **按Enter返回!");
    }//outputStudent
    
    //输出课程信息
    void outputSubject()
    {
        struct subject *head, *p;
        p = head = loadSubject();
        printf("\n\n\t\t\t    *******课 程 信 息*******\n");
        printf("\t\t ============================================\n");
        printf("\t\t 课程号   课程名\t类别\t学分\t学期\n");
        printf("\t\t ============================================\n");
        while (p)
        {
            printf("\t\t  %s\t %s\t%s\t%g\t%d\n", p ->subNum, p ->subName, p ->cate, p ->credit, p ->term);
            p = p ->next;
        }
        printf("\t\t ============================================\n");
        printf("\n **按Enter返回!");
    }//outputSubject
    
    //输出课程成绩
    void outputStScore()
    {
        struct stscore *head_sc, *p;
        struct student *head_st, *q;
        struct subject *head_sub, *r;
        int term;
        char t[3];
        char subname[10][20], sn[10][20];
        int cnt, k;
    
        printf("请输入学期:");
        scanf("%d", &term);
        t[0] = '0' + term - 0;
        t[1] = '\0';
        //查找该学期的所有课程
        r = head_sub = loadSubject();
        head_st = loadStudent();
        cnt = 1;
        while (r)
        {
            if (r ->term == term)
            {
                strcpy(sn[cnt], r ->subName);
                strcat(sn[cnt], "_");
                strcat(sn[cnt], t);
                strcat(sn[cnt], ".txt");
                strcpy(subname[cnt++], r ->subName);
            }
            r = r ->next;
        }
    
        //输出该学期课程选择
        system("cls");
        printf("\n\t\t\t\t ***课程成绩查询***\n");
        printf(" \t\t\t     =========================\n");
        for (int i = 1; i < cnt; i++)
        {
            printf("\t\t\t\t%d ---- %s\n\n", i, subname[i]);
        }
        printf(" \t\t\t     =========================\n");
        printf("\t\t\t     请选择:");
        scanf("%d", &k);
    
        //输出课程成绩
        system("cls");
        p = head_sc = loadStscore(sn[k]);
        printf("\n\n\t\t          *******课 程 成 绩 信 息*******\n");
        printf("\t\t ==============================================\n");
        printf("\t\t  **课程编号:%s\n", head_sc ->subNum);
        printf("\t\t  **课程名:%s\n", subname[k]);
        printf("\t\t ==============================================\n");
        printf("\t\t    学 号   \t姓名\t   成绩\t     是否重修\n");
        printf("\t\t ==============================================\n");
        while (p)
        {
            printf("\t\t  %s\t", p ->stnum);
            q = head_st;
            while (q)
            {
                if (strcmp(q->stnum, p ->stnum) == 0)
                {
                    printf("%s", q ->stname);
                    break;
                }
                q = q ->next;
            }
            printf("      %d\t        %s\n", p ->mark, p ->repair);
            p = p ->next;
        }//while
        printf("\t\t ==============================================\n");
        printf("\n **按Enter返回!");
    }//outputStScore
    
    //输出学生品行分
    void outputStCondSc()
    {
        struct stCondSc *head, *p;
        struct student *head_st, *q;
        p = head = loadstCondSc();
        q = head_st = loadStudent();
    
        printf("\n\n\t    \t\t*******品 行 成 绩 信 息*******\n");
        printf("\t ================================================================\n");
        printf("\t    学  号   \t姓  名\t 辅导员评分\t班主任评分\t班级评分\n");
        printf("\t ================================================================\n");
        while (p)
        {
            printf("\t %s\t", p ->stnum);
            q = head_st;
            while (q)
            {
                if (strcmp(q->stnum, p ->stnum) == 0)
                {
                    printf("%s", q ->stname);
                    break;
                }
                q = q ->next;
            }
            printf("      %d\t\t   %d\t\t   %d\n", p ->coumark, p ->headmark, p ->classsmark);
            p = p ->next;
        }
        printf("\t ================================================================\n");
        printf("\n **按Enter返回!");
    }//outputStCondSc
    
    //输出学生综合信息
    void outputCominfo()
    {
        struct cominfo *head, *p;
        p = head = loadstCominfo();
         printf("    \t\t*******学 生 综 合 信 息*******\n");
        printf(" =========================================================\n");
        printf("    学  号   \t姓名\t   综合分\n");
        printf("      \t\t获奖类别  奖励分值  获奖日期\n");
        printf("      \t\t惩处类别  惩罚分值  惩处日期\n");
        printf(" ---------------------------------------------------------\n");
        while (p)
        {
            printf(" %s\t%s\t     %d\n", p ->stnum, p ->stname, p ->getcredit);
            printf("                  %s\t     %d\t    %d-%d-%d\n", p ->awdlev, p ->amark, p ->ayear, p ->amon, p ->aday);
            printf("                  %s\t     %d\t    %d-%d-%d\n", p ->puncate, p ->pmark, p ->pyear, p ->pmon, p ->pday);
            printf(" ---------------------------------------------------------\n");
            p = p ->next;
        }
        printf("\n **按Enter返回!");
    }//outputCominfo
    
    /* ***** 统计分析 ********* */
    //某门课程按分数段成绩统计
    void countSubScore()
    {
        struct stscore *head_sc, *p;
        struct student *head_st, *q;
        struct subject *head_sub, *r;
        //   总      90+      75+      60+
        int cnt = 0, cn1 = 0, cn2 = 0, cn3 = 0, cn4 = 0;
        struct stscore *c1[20], *c2[20], *c3[20], *c4[20];
        float per;
        int term, key;
        char t[3];
        char subname[10][20], sn[10][20];
        int cntt, k;
    
        printf("请输入学期:");
        scanf("%d", &term);
        t[0] = '0' + term - 0;
        t[1] = '\0';
        //查找该学期的所有课程
        r = head_sub = loadSubject();
        //head_st = loadStudent();
        cntt = 1;
        while (r)
        {
            if (r ->term == term)
            {
                strcpy(sn[cntt], r ->subName);
                strcat(sn[cntt], "_");
                strcat(sn[cntt], t);
                strcat(sn[cntt], ".txt");
                strcpy(subname[cntt++], r ->subName);
            }
            r = r ->next;
        }
    
        //输出该学期课程选择
        system("cls");
        printf("\n\t\t\t\t ***课程成绩查询***\n");
        printf(" \t\t\t     =========================\n");
        for (int i = 1; i < cntt; i++)
        {
            printf("\t\t\t\t%d ---- %s\n\n", i, subname[i]);
        }
        printf(" \t\t\t     =========================\n");
        printf("\t\t\t     请选择:");
        scanf("%d", &k);
    
        p = head_sc = loadStscore(sn[k]);
        while (p)
        {
            if (p ->mark >= 90)
                c1[cn1++] = p;
            else if (p ->mark >= 75)
                c2[cn2++] = p;
            else if (p ->mark >= 60)
                c3[cn3++] = p;
            else
                c4[cn4++] = p;
            cnt++;
            p = p ->next;
        }//while
        per = (cn1+cn2+cn3) / float(cnt);
        system("cls");
        printf("\n\n\t\t     **课程信息统计分析***\n\n");
        printf("\t\t 课程名称:%s\n", subname[k]);
        printf("\t\t 及格率:  %g%%\n", 100*per);
        printf("\t\t ==========================\n");
        printf("\t\t    分数段       人数\n");
        printf("\t\t    90~100:       %d\n", cn1);
        printf("\t\t    75~89:        %d\n", cn2);
        printf("\t\t    60~74:        %d\n", cn3);
        printf("\t\t    0~59:         %d\n", cn4);
        printf("\t\t ==========================\n");
        printf("\n\t\t是否要输出各分数段学生?\n");
        printf("\t\t 1 - 是   0 - 否\n");
        printf("\t\t 请选择:");
        scanf("%d", &key);
        if (key)
        {
            system("cls");
            head_st = loadStudent();
            printf("\n\t\t              **各分数段学生**\n");
            printf("\t\t===============================================\n");
            printf("\t\t   学 号   \t姓名\t   成绩\t 是否重修\n");
            printf("\t\t===============================================\n");
            printf("\t  90~100: \n");
            for (int i = 0; i < cn1; i++)
            {
                printf("\t        %s\t", c1[i] ->stnum);
                q = head_st;
                while (q)
                {
                    if (strcmp(q ->stnum, c1[i] ->stnum) == 0)
                    {
                        printf("%s", q ->stname);
                        break;
                    }
                    q = q ->next;
                }
                printf("      %d\t", c1[i] ->mark);
                printf("    %s\n", c1[i] ->repair);
            }//for
            printf("\t  75~89: \n");
            for (int i = 0; i < cn2; i++)
            {
                printf("\t        %s\t", c2[i] ->stnum);
                q = head_st;
                while (q)
                {
                    if (strcmp(q ->stnum, c2[i] ->stnum) == 0)
                    {
                        printf("%s", q ->stname);
                        break;
                    }
                    q = q ->next;
                }
                printf("      %d\t", c2[i] ->mark);
                printf("    %s\n", c2[i] ->repair);
            }//for
    
            printf("\t  60~74: \n");
            for (int i = 0; i < cn3; i++)
            {
                printf("\t        %s\t", c3[i] ->stnum);
                q = head_st;
                while (q)
                {
                    if (strcmp(q ->stnum, c3[i] ->stnum) == 0)
                    {
                        printf("%s", q ->stname);
                        break;
                    }
                    q = q ->next;
                }
                printf("      %d\t", c3[i] ->mark);
                printf("    %s\n", c3[i] ->repair);
            }//for
            printf("\t  0~59: \n");
            for (int i = 0; i < cn4; i++)
            {
                printf("\t        %s\t", c4[i] ->stnum);
                q = head_st;
                while (q)
                {
                    if (strcmp(q ->stnum, c4[i] ->stnum) == 0)
                    {
                        printf("%s", q ->stname);
                        break;
                    }
                    q = q ->next;
                }
                printf("      %d\t", c4[i] ->mark);
                printf("    %s\n", c4[i] ->repair);
            }//for
        }//if
        printf("\t\t===============================================\n");
        printf("\n\n统计分析完毕,按Enter返回!\n");
    }//countSubScore
    
    //业务课程平均分按分数段统计
    void countAveScore()
    {
        struct stscore *head_sc, *p;
        struct stscore *head_sc2, *q;
        struct subject *head_sub, *r;
        char subname[20][20], t[3];
        //   总      90+      75+      60+
        int cn1 = 0, cn2 = 0, cn3 = 0, cn4 = 0;
        int term, cnt;
    
        printf("请输入学期:");
        scanf("%d", &term);
        t[0] = '0' + term - 0;
        t[1] = '\0';
        r = head_sub = loadSubject();
    
        cnt = 0;
        while (r)
        {
            if (r ->term == term)
            {
                strcpy(subname[cnt], r ->subName);
                strcat(subname[cnt], "_");
                strcat(subname[cnt], t);
                strcat(subname[cnt], ".txt");
                cnt++;
            }
            r = r ->next;
        }//while
    
        head_sc2 = loadStscore(subname[0]);
        for (int i = 1; i < cnt; i++)
        {
            p = head_sc = loadStscore(subname[i]);
            while (p)
            {
                q = head_sc2;
                while (q && strcmp(p ->stnum, q ->stnum)!=0)
                {
                    q = q ->next;
                }
                if (q)
                    q ->mark += p ->mark;
                p = p ->next;
            }
        }//for
        float sum;
        p = head_sc2;
        cnt--;
        while (p)
        {
            sum =  p ->mark / cnt;
            if (sum >= 90)
                cn1++;
            else if (sum >= 75)
                cn2++;
            else if (sum >= 60)
                cn3++;
            else
                cn4++;
            p = p ->next;
        }//while
    
        printf("\n\n\t\t\t    **各分数段人数**\n");
        printf("\t\t\t  =====================\n");
        printf("\t\t\t    分数段        人数\n");
        printf("\t\t\t  =====================\n");
        printf("\t\t\t    90~100:        %d\n", cn1);
        printf("\t\t\t    75~89:         %d\n", cn2);
        printf("\t\t\t    60~74:         %d\n", cn3);
        printf("\t\t\t    0~59:          %d\n", cn4);
        printf("\t\t\t  =====================\n");
        printf("\n\n **统计分析完毕,按Enter返回!\n");
    }//countAveScore
    
    //根据学号从小到大对成绩进行排序
    struct stscore * sortGrade(struct stscore *head)
    {
        struct stscore *head_new, *p, *r, *s, *t;
        head_new = (struct stscore *)malloc(sizeof(struct stscore));
        p = head;
        head_new ->next = p;
        p = p ->next;
        head_new ->next ->next = NULL;
        while (p)
        {
            t = p ->next;
            r = head_new ->next;
            s = head_new;
            while (r!=NULL && strcmp(p ->stnum, r ->stnum)>0)
            {
                s = r;
                r = r ->next;
            }
            s ->next = p;
            p ->next = r;
            p = t;
        }
        return head_new ->next;
    }//sortGrade
    
    //统计任意一名同学每门功课的班级排名以及业务课成绩总体排名
    void countStScore()
    {
        struct stscore *head_sc, *p, *q;
        struct student *stu, *r;
        struct subject *head_sub, *f;
        int t, cnt, k;
        char term[3];
        char subname[10][20], sn[10][20];
    
        printf("请输入学期:");
        scanf("%d", &t);
        term[0] = '0' + t - 0;
        term[1] = '\0';
    
        //择取相应学期课程
        cnt = 1;
        f = head_sub = loadSubject();
        while (f)
        {
            if (f ->term == t)
            {
                strcpy(subname[cnt], f ->subName);
                strcpy(sn[cnt], subname[cnt]);
                strcat(subname[cnt], "_");
                strcat(subname[cnt], term);
                strcat(subname[cnt], ".txt");
                cnt++;
            }
            f = f ->next;
        }
    
        //输出课程
        system("cls");
        printf("\n\t\t\t\t ***成绩排名统计***\n");
        printf(" \t\t\t     =========================\n");
        for (int i = 1; i < cnt; i++)
        {
            printf("\t\t\t\t%d ---- %s\n\n", i, sn[i]);
        }
        printf(" \t\t\t     =========================\n");
        printf("\t\t\t     请选择:");
        scanf("%d", &k);
        //统计排名
        p = head_sc = loadStscore(subname[k]);
        while (p)
        {
            p ->cnt = 1;
            q = head_sc;
            while (q)
            {
                if (q ->mark > p ->mark)
                {
                    p ->cnt++;
                }
                q = q ->next;
            }
            p = p ->next;
        }//while
    
        system("cls");
        printf("\n\n                       ***学生业务课程成绩***\n");
        printf("                              排名统计\n");
        printf("\n                 课程名:%s\n", sn[k]);
        printf(" \t    ==========================================\n");
        printf("  \t\t  学  号         姓  名\t     排名\n");
        printf(" \t    ==========================================\n");
        p = head_sc;
        stu = loadStudent();
        while (p)
        {
            printf("\t\t%s", p ->stnum);
            r = stu;
            while (r)
            {
                if (strcmp(r ->stnum, p ->stnum) == 0)
                {
                    printf("       %s", r ->stname);
                    break;
                }
                r = r ->next;
            }
            printf("\t      %d\n", p ->cnt);
            p = p ->next;
        }//while
        printf(" \t    ==========================================\n");
        printf("\n**统计完毕,按Enter返回!");
    }//countStScore
    
    //以宿舍为单位进行成绩统计分析
    void countDorRank()
    {
        struct student *head_st, *p;
        struct subject *head_sub, *q;
        struct stscore *head_sc[10], *f;
        char dor_num[10];
        char subname[10][20], sn[10][20];
        int t, cnt;
        char term[3];
    
        printf("请输入学期:");
        scanf("%d", &t);
        term[0] = '0' + t - 0;
        term[1] = '\0';
        q = head_sub = loadSubject();
        cnt = 1;
        while (q)
        {
            if (q ->term == t)
            {
                strcpy(sn[cnt], q ->subName);
                strcpy(subname[cnt], sn[cnt]);
                strcat(subname[cnt], "_");
                strcat(subname[cnt], term);
                strcat(subname[cnt], ".txt");
                cnt++;
            }
            q = q ->next;
        }//while
    
        p = head_st = loadStudent();
        for (int i = 1; i < cnt; i++)
            head_sc[i] = loadStscore(subname[i]);
        printf("请输入宿舍号:");
        scanf("%s", dor_num);
        system("cls");
        printf("\n                    *宿舍成员成绩统计分析*\n");
        printf("\n  宿舍号:%s\n", dor_num);
        printf(" ========================================================================\n");
        printf("   学 号\t  姓 名\t   ");
        for (int i = 1; i < cnt; i++)
            printf("%s  ", sn[i]);
        printf("\n");
        printf(" ========================================================================\n");
        while (p)
        {
            if (strcmp(p ->dornum, dor_num) == 0)
            {
                printf(" %s", p ->stnum);
                printf("      %s", p ->stname);
                for (int i = 1; i < cnt; i++)
                {
                    f = head_sc[i];
                    while (f && strcmp(p ->stnum, f->stnum)!=0)
                        f = f ->next;
                    if (f)
                        printf("%11d", f ->mark);
                    else
                        printf("        无");
                }
                printf("\n");
            }//if
            p = p ->next;
        }//while
        printf(" ========================================================================\n");
        printf("\n**统计完毕,按Enter返回!");
    }//countDorRank
    
    //分学期统计挂科
    void countFail()
    {
        struct student *head_st, *q;
        struct subject *head_sub, *r;
        struct stscore *head_sc[10], *p;
        int t, cnt, tt;
        char term[3];
        char subname[10][20];
    
        printf("请输入学期:");
        scanf("%d", &tt);
        term[0] = '0' + tt - 0;
        term[1] = '\0';
        r = head_sub = loadSubject();
        cnt = 1;
    
        //选课程
        while (r)
        {
            if (r ->term == tt)
            {
                strcpy(subname[cnt], r ->subName);
                strcat(subname[cnt], "_");
                strcat(subname[cnt], term);
                strcat(subname[cnt], ".txt");
                head_sc[cnt] = loadStscore(subname[cnt]);
                cnt++;
            }
            r = r ->next;
        }//while
    
        q = head_st = loadStudent();
        while (q)
        {
            q ->stage = 0;
            for (int i = 1; i < cnt; i++)
            {
                p = head_sc[i];
                while (p && strcmp(p ->stnum, q ->stnum)!=0)
                    p = p ->next;
                if (p)
                {
                    if (p ->mark < 60)
                        q ->stage++;
                }
            }//for
            q = q ->next;
        }//while
        system("cls");
        printf("\t\t               **分学期统计挂科次数**\n");
        printf("\n\t\t **学期:%d\n", tt);
        printf("\t\t =========================================\n");
        q = head_st;
        t = 1;
        printf("\t\t 序号     学 号\t\t 姓 名\t 挂科次数\n");
        printf("\t\t =========================================\n");
        while (q)
        {
            printf("\t\t%5d    %s     %s      %d\n", t++, q ->stnum, q ->stname, q ->stage);
            q = q ->next;
        }
        printf("\t\t =========================================\n");
        printf("\n **统计输出完成,按Enter返回!");
    }//countFail
    
    //以业务课班级排名为依据分学期对比分
    void countChange()
    {
        int cnt = 1;
        struct stscore *head_sc1[10], *head_sc2[10], *p, *q;
        struct student *head_st, *r;
        struct subject *head_sub, *f;
        char subname_1[10][20];
        char subname_2[10][20];
        int t1, t2, n1, n2;
        char term1[3], term2[3];
    
        printf("请输入学期一:");
        scanf("%d", &t1);
        term1[0] = '0' + t1 - 0;
        term1[1] = '\0';
        printf("请输入学期二:");
        scanf("%d", &t2);
        term2[0] = '0' + t2 - 0;
        term2[1] = '\0';
    
        n1 = 1;
        f = head_sub = loadSubject();
        while (f)
        {
            if (f ->term == t1)
            {
                strcpy(subname_1[n1], f ->subName);
                strcat(subname_1[n1], "_");
                strcat(subname_1[n1], term1);
                strcat(subname_1[n1], ".txt");
                head_sc1[n1] = loadStscore(subname_1[n1]);
                n1++;
            }
            f = f ->next;
        }//while
        n2 = 1;
        f = head_sub;
        while (f)
        {
            if (f ->term == t2)
            {
                strcpy(subname_2[n2], f ->subName);
                strcat(subname_2[n2], "_");
                strcat(subname_2[n2], term2);
                strcat(subname_2[n2], ".txt");
                head_sc2[n2] = loadStscore(subname_2[n2]);
                n2++;
            }
            f = f ->next;
        }//while
    
        //算成绩
        for (int i = 2; i < n1; i++)
        {
            p = head_sc1[1];
            while (p)
            {
                q = head_sc1[i];
                while (q)
                {
                    if (strcmp(p ->stnum, q ->stnum) == 0)
                    {
                        p ->mark += q ->mark;
                        break;
                    }
                    q = q ->next;
                }//while
                p = p ->next;
            }//while
        }//for
        for (int i = 2; i < n2; i++)
        {
            p = head_sc2[1];
            while (p)
            {
                q = head_sc2[i];
                while (q)
                {
                    if (strcmp(p ->stnum, q ->stnum) == 0)
                    {
                        p ->mark += q ->mark;
                        break;
                    }
                    q = q ->next;
                }//while
                p = p ->next;
            }//while
        }//for
    
        //统计名次
        p = head_sc1[1];
        while (p)
        {
            p ->cnt = 1;
            q = head_sc1[1];
            while (q)
            {
                if (q ->mark > p ->mark)
                    p ->cnt++;
                q = q ->next;
            }
            p = p ->next;
        }
        p = head_sc2[1];
        while (p)
        {
            p ->cnt = 1;
            q = head_sc2[1];
            while (q)
            {
                if (q ->mark > p ->mark)
                    p ->cnt++;
                q = q ->next;
            }
            p = p ->next;
        }
    
        system("cls");
        head_st = loadStudent();
        printf("\n\n\t                  **学生成绩排名统计**\n");
        printf("\t ===========================================================\n");
        printf("\t 序号     学 号\t\t 姓 名\t 第%d学期  第%d学期  排名变动\n", t1, t2);
        printf("\t ===========================================================\n");
        p = head_sc1[1];
        while (p)
        {
            printf("\t%5d    %s", cnt++, p ->stnum);
            r = head_st;
            while (r && strcmp(r ->stnum, p ->stnum)!=0)
            {
                r = r ->next;
            }
            if (r)
                printf("     %s", r ->stname);
            printf("%7d", p ->cnt);
            q = head_sc2[1];
            while (q)
            {
                if (strcmp(p ->stnum, q ->stnum) == 0)
                {
                    printf("%9d", q ->cnt);
                    printf("%9d\n", p ->cnt - q ->cnt);
                }
                q = q ->next;
            }
            p = p ->next;
        }//while
        printf("\t ===========================================================\n");
        printf("\n **统计输出完成,按Enter返回!");
    }//countChange
    
    //按课程成绩(高->低)对学生排序
    void subStScoreSort()
    {
        struct stscore *head_new, *r, *s;
        struct stscore *head, *p, *t;
        struct subject *head_sub, *q;
        char subname[10][20], sn[10][20];
        int k, tt, cnt, key;
        char term[3];
    
        head_new = (struct stscore *)malloc(sizeof(struct stscore));
        printf("请输入课程学期:");
        scanf("%d", &tt);
        term[0] = '0' + tt - 0;
        term[1] = '\0';
    
        cnt = 1;
        q = head_sub = loadSubject();
        while (q)
        {
            if (q ->term == tt)
            {
                strcpy(subname[cnt], q ->subName);
                strcpy(sn[cnt], subname[cnt]);
                strcat(subname[cnt], "_");
                strcat(subname[cnt], term);
                strcat(subname[cnt], ".txt");
                cnt++;
            }
            q = q ->next;
        }
    
        printf("\t\t\t**第%d学期课程**\n", tt);
        printf("\t\t==================================\n");
        for (int i = 1; i < cnt; i++)
            printf("\t\t  %d  --  %s\n\n", i, sn[i]);
        printf("\t\t==================================\n");
        printf("\t\t  请选择:");
        scanf("%d", &key);
        p = head = loadStscore(subname[key]);
    
        head_new ->next = p;
        p = p ->next;
        head_new ->next ->next = NULL;
        while (p)
        {
            t = p ->next;
            r = head_new ->next;
            s = head_new;
            while (r!=NULL && p ->mark < r ->mark)
            {
                s = r;
                r = r ->next;
            }
            s ->next = p;
            p ->next = r;
            p = t;
        }
        printf("\n\t\t是否输出排序后成绩信息?\n");
        printf("\t\t 1 - 是    0 - 否\n");
        printf("\n\t\t请选择:");
        scanf("%d", &k);
        if (1 == k)
        {
            system("cls");
            printf("\n\n\t\t                 **课程成绩排序**\n\n");
                printf("\n\t\t  课程名:%s\n", sn[key]);
                printf("\t\t =========================================\n");
    
            r = head_new ->next;
            int num = 1;
            printf("\t\t  名次     学 号\t成绩   是否重修\n");
                printf("\t\t =========================================\n");
            while (r)
            {
                printf("\t\t   %d\t%s\t%d\t  %s\n", num++, r ->stnum, r ->mark, r ->repair);
                r = r ->next;
            }
            printf("\t\t =========================================\n");
        }//if
        printf("\n **按Enter返回!");
        getchar();
    }//subStScoreSort
    
    //按挂科门次(高->低)对学生排序
    void failStcntSort()
    {
        struct stscore *head_new, *r, *s, *t;
        struct subject *head_sub, *f;
        struct stscore *head_sc1, *head_sc, *p, *q;
        struct student *head_st, *u;
        char subname[10][20];
        int tt, cnt;
        char term[3];
        head_new = (struct stscore *)malloc(sizeof(struct stscore));
    
        printf("请输入学期:");
        scanf("%d", &tt);
        term[0] = '0' + tt - 0;
        term[1] = '\0';
        f = head_sub = loadSubject();
        cnt = 1;
        while (f)
        {
            if (f ->term == tt)
            {
                strcpy(subname[cnt], f ->subName);
                strcpy(subname[cnt], f ->subName);
                strcat(subname[cnt], "_");
                strcat(subname[cnt], term);
                strcat(subname[cnt], ".txt");
                cnt++;
            }
            f = f ->next;
        }//while
    
        p = head_sc1 = loadStscore(subname[1]);
        while (p)
        {
            p ->cnt = 0;
            if (p ->mark < 60)
                p ->cnt++;
            p = p ->next;
        }
        for (int i = 2; i < cnt; i++)
        {
            p = head_sc1;
            head_sc = loadStscore(subname[i]);
            while (p)
            {
                q = head_sc;
                while (q)
                {
                    if (strcmp(p ->stnum, q ->stnum) == 0)
                    {
                        if (q ->mark < 60)
                        {
                            p ->cnt++;
                            break;
                        }
                    }
                    q = q ->next;
                }//while
                p = p ->next;
            }//while
        }//for
    
        //排序
        p = head_sc1;
        head_new ->next = p;
        p = p ->next;
        head_new ->next ->next = NULL;
        while (p)
        {
            t = p ->next;
            r = head_new ->next;
            s = head_new;
            while (r!=NULL && p ->cnt < r ->cnt)
            {
                s = r;
                r = r ->next;
            }
            s ->next = p;
            p ->next = r;
            p = t;
        }
    
        //输出
        system("cls");
        head_st = loadStudent();
        printf("\n\n\t\t\t     **挂科信息统计排序**\n");
        printf("\t\t============================================\n");
        r = head_new ->next;
        int num = 1;
        printf("\t\t 名次     学  号\t姓  名    挂科次数\n");
        printf("\t\t============================================\n");
        while (r)
        {
            printf("\t\t  %d\t%s\t", num++, r ->stnum);
            u = head_st;
            while (u)
            {
                if (strcmp(u ->stnum, r ->stnum) == 0)
                    printf("%s", u ->stname);
                u = u ->next;
            }
            printf("        %d\n", r ->cnt);
            r = r ->next;
        }
        printf("\t\t============================================\n");
        getchar();
        printf("\n **排序输出完毕,按Enter返回!\n");
    }//failStcntSort
    
    struct
    {
        int a, b;
        float per;
        char subname[20];
        char subnum[10];
    }ssub[10];
    
    //按不及格学生数对课程进行由高到低排序
    void failSubSort()
    {
        struct stscore *head_sc, *p;
        struct subject *head_sub, *f;
        char subname[10][20], sn[10][20];
        int t, cnt;
        char term[3];
    
        printf("请输入学期:");
        scanf("%d", &t);
        term[0] = '0' + t - 0;
        term[1] = '\0';
        f = head_sub = loadSubject();
        cnt = 1;
        while (f)
        {
            if (f ->term == t)
            {
                strcpy(subname[cnt], f ->subName);
                strcpy(sn[cnt], f ->subName);
                strcat(subname[cnt], "_");
                strcat(subname[cnt], term);
                strcat(subname[cnt], ".txt");
                cnt++;
            }
            f = f ->next;
        }//while
    
        for (int i = 1; i < cnt; i++)
        {
            ssub[i].b = 0;
            ssub[i].a = 0;
            p = head_sc = loadStscore(subname[i]);
            strcpy(ssub[i].subname, sn[i]);
            strcpy(ssub[i].subnum, p ->subNum);
            while (p)
            {
                ssub[i].a++;
                if (p ->mark < 60)
                    ssub[i].b++;
                p = p ->next;
            }
            ssub[i].per =100 * (float)ssub[i].b / float(ssub[i].a);
        }//for
        for (int i = 1; i < cnt-1; i++)
        {
            for (int j = i+1; j < cnt; j++)
            {
                if (ssub[i].b < ssub[j].b)
                {
                    ssub[3] = ssub[i];
                    ssub[i] = ssub[j];
                    ssub[j] = ssub[3];
                }
            }
        }//for
        system("cls");
        printf("\n\n\t\t\t        **第%d学期课程挂科率**\n", t);
        printf("\t\t\t               统计排名\n");
        printf("\t\t =================================================\n");
        printf("\t\t  课程编号     课程名称\t      挂科人数     挂科率\n");
        printf("\t\t =================================================\n");
        for (int i = 1; i < cnt; i++)
        {
            printf("\t\t%7s%19s%10d%10g%%\n", ssub[i].subnum, ssub[i].subname, ssub[i].b, ssub[i].per);
        }
        printf("\t\t =================================================\n");
        printf("\n **排序输出完毕,按Enter返回!\n");
        getchar();
    }//failSubSort
    
    //根据成绩从高到低学生进行排序
    struct student * sortGrade(struct student *head)
    {
        struct student *head_new, *p, *r, *s, *t;
        head_new = (struct student *)malloc(sizeof(struct student));
        p = head;
        head_new ->next = p;
        p = p ->next;
        head_new ->next ->next = NULL;
        while (p)
        {
            t = p ->next;
            r = head_new ->next;
            s = head_new;
            while (r!=NULL && p ->stage < r ->stage )
            {
                s = r;
                r = r ->next;
            }
            s ->next = p;
            p ->next = r;
            p = t;
        }
        return head_new ->next;
    }//sortGrade
    
    //以宿舍为单位按成绩由高到低进行排序
    void dorScoreSort()
    {
        struct student *head_st, *p;
        struct student *head_st_dor, *r;
        struct stscore *head_sub[10], *q;
        struct subject *head, *f;
        int t, m, tt, cnt;
        float cont = 0;
        char term[3];
        char subname[10][20];
        char dor[10];
    
        printf("请输入学期:");
        scanf("%d", &tt);
        term[0] = '0' + tt - 0;
        term[1] = '\0';
        printf("请输入宿舍号:");
        scanf("%s", dor);
        cnt = 1;
        f = head = loadSubject();
        while (f)
        {
            if (f ->term == tt)
            {
                strcpy(subname[cnt], f ->subName);
                strcat(subname[cnt], "_");
                strcat(subname[cnt], term);
                strcat(subname[cnt], ".txt");
                head_sub[cnt] = loadStscore(subname[cnt]);
                cnt++;
            }
            f = f ->next;
        }//while
    
        r = head_st_dor = (struct student *)malloc(sizeof(struct student));
        p = head_st = loadStudent();
        while (p)
        {
            if (strcmp(p ->dornum, dor) == 0)
            {
                r ->next = p;
                r = p;
            }
            p = p ->next;
        }//while
        r ->next = NULL;
    
        r = head_st_dor ->next;
        t = 0;
        while (r)
        {
            r ->stage = 0;
            for (int i = 1; i < cnt; i++)
            {
                q = head_sub[i];
                while (q)
                {
                    if (strcmp(q ->stnum, r ->stnum) == 0)
                        r ->stage+= q ->mark;
                    q = q ->next;
                }
            }//for
            t++;
            r ->stage /= (cnt-1);
            cont += r ->stage;
            r = r ->next;
        }//while
        cont /= t;
    
        system("cls");
        printf("\n\t\t                 **宿舍成绩排名**\n");
        printf("\n\t\t **宿舍号:%s\n", dor);
        printf("\t\t **宿舍平均成绩:%g\n", cont);
        printf("\t\t ====================================\n");
        printf("\t\t   序号     学 号\t 姓 名\t 成绩\n");
        printf("\t\t ====================================\n");
        r = head_st_dor ->next = sortGrade(head_st_dor ->next);
        m = 1;
        while (r)
        {
            printf("\t\t%5d    %s     %s%6d\n", m++, r ->stnum, r ->stname, r ->stage);
            r = r ->next;
        }
        printf("\t\t ====================================\n");
        printf("\n\n **排序输出完毕,按Enter返回!");
        getchar();
    }//dorScoreSort
    
    //根据成绩从高到低学生进行排序
    struct cominfo * sortGradeA(struct cominfo *head)
    {
        struct cominfo *head_new, *p, *r, *s, *t;
        head_new = (struct cominfo *)malloc(sizeof(struct cominfo));
        p = head;
        head_new ->next = p;
        p = p ->next;
        head_new ->next ->next = NULL;
        while (p)
        {
            t = p ->next;
            r = head_new ->next;
            s = head_new;
            while (r!=NULL && p ->amark < r ->amark)
            {
                s = r;
                r = r ->next;
            }
            s ->next = p;
            p ->next = r;
            p = t;
        }
        return head_new ->next;
    }//sortGrade
    
    //根据奖励对学生进行由高到低排序
    void awdStSort()
    {
        struct cominfo *head, *p;
        int cnt = 1;
    
        head = loadstCominfo();
        p = head =sortGradeA(head);
        printf("\n\t\t        **学生奖励信息排名**\n");
        printf("\t\t ====================================\n");
        printf("\t\t   序号     学 号\t 姓 名\t 成绩\n");
        printf("\t\t ====================================\n");
        while (p)
        {
            printf("\t\t%5d    %s     %s%6d\n", cnt++, p ->stnum, p ->stname, p ->amark);
            p = p ->next;
        }
        printf("\t\t ====================================\n");
        printf("\n\n **排序输出完毕,按Enter返回!");
    }//awdStSort
    
    //根据成绩从高到低学生进行排序
    struct cominfo * sortGradeP(struct cominfo *head)
    {
        struct cominfo *head_new, *p, *r, *s, *t;
        head_new = (struct cominfo *)malloc(sizeof(struct cominfo));
        p = head;
        head_new ->next = p;
        p = p ->next;
        head_new ->next ->next = NULL;
        while (p)
        {
            t = p ->next;
            r = head_new ->next;
            s = head_new;
            while (r!=NULL && p ->pmark > r ->pmark)
            {
                s = r;
                r = r ->next;
            }
            s ->next = p;
            p ->next = r;
            p = t;
        }
        return head_new ->next;
    }//sortGrade
    
    //根据惩罚情况对学生由低到高排序
    void punStScore()
    {
        struct cominfo *head, *p;
        int cnt = 1;
    
        head = loadstCominfo();
        p = head =sortGradeP(head);
        printf("\n\t\t        **学生惩处信息排名**\n");
        printf("\t\t ====================================\n");
        printf("\t\t   序号     学 号\t 姓 名\t 成绩\n");
        printf("\t\t ====================================\n");
        while (p)
        {
            printf("\t\t%5d    %s     %s%6d\n", cnt++, p ->stnum, p ->stname, p ->pmark);
            p = p ->next;
        }
        printf("\t\t ====================================\n");
        printf("\n\n **排序输出完毕,按Enter返回!");
    }//punStScore
    
    //根据品行分排序
    struct stCondSc * SortStcondSc(struct stCondSc *head)
    {
        struct stCondSc *head_new, *p, *r, *s, *t;
        head_new = (struct stCondSc *)malloc(sizeof(struct stCondSc));
        p = head;
        head_new ->next = p;
        p = p ->next;
        head_new ->next ->next = NULL;
        while (p)
        {
            t = p ->next;
            r = head_new ->next;
            s = head_new;
            while (r!=NULL && p ->conductmark < r ->conductmark)
            {
                s = r;
                r = r ->next;
            }
            s ->next = p;
            p ->next = r;
            p = t;
        }//while
        return head_new ->next;
    }//SortStcondSc
    
    //奖学金评定
    void schoshipAsse()
    {
        int tt;
        char term[3];
        int cnt, n, m;
        struct subject *head, *f;//课程信息
        struct cominfo *head_com, *q; //综合信息
        struct stscore *head_sub[10], *p; //课程成绩
        struct stCondSc *head_con, *r; //品行成绩
        struct student *head_st, *t; //基本信息
        char subname[10][20];
        head = loadSubject();
        head_st = loadStudent();
        head_con = loadstCondSc();
        head_con = SortStcondSc(head_con);
    
        printf("请输入学期:");
        scanf("%d", &tt);
        term[0] = '0' + tt - 0;
        term[1] = '\0';
        f = head;
        m = 0;
        while (f)
        {
            if (f ->term == tt)
            {
                strcpy(subname[m], f ->subName);
                strcat(subname[m], "_");
                strcat(subname[m], term);
                strcat(subname[m], ".txt");
                head_sub[m] = loadStscore(subname[m]);
                m++;
            }
            f = f ->next;
        }//while
    
        cnt = 0;
        r = head_con;
        while (r)
        {
            cnt++;
            r ->conductmark = cnt;
            r ->classsmark = 0;
            r = r ->next;
        }
    
        //判断品行分(前70%)
        n = cnt * 0.7;
        r = head_con;
        while (r)
        {
            if (r ->conductmark > n)
                r ->classsmark++;
            r = r ->next;
        }
    
        //判断挂科
        r = head_con;
        while (r)
        {
            if (r ->classsmark == 0)
            {
                for (int i = 1; i < m; i++)
                {
                    if (r ->classsmark == 0)
                    {
                        int flag = 1;
                        p = head_sub[i];
                        while (p)
                        {
                            if (strcmp(r ->stnum, p ->stnum) == 0)
                            {
                                if (p ->mark < 60)
                                {
                                    r ->classsmark++;
                                    flag = 0;
                                    break;
                                }
                            }
                            p = p ->next;
                        }//while
                        if (flag == 0)
                            break;
                    }//if
                }//for
            }//if
            r = r ->next;
        }//while
    
        //判断惩处情况
        head_com = loadstCominfo();
        r = head_con;
        while (r)
        {
            if (r ->classsmark == 0)
            {
                q = head_com;
                while (q)
                {
                    if (strcmp(q ->stnum, r ->stnum) == 0)
                        if (q ->pmark < 0)
                            r ->classsmark++;
                    q = q ->next;
                }
            }//if
            r = r ->next;
        }//while
    
        struct stCondSc *head_new, *s;
        head_new = (struct stCondSc *)malloc(sizeof(struct stCondSc));
        s = head_new;
        r = head_con;
        while (r)
        {
            if (r ->classsmark == 0)
            {
                s ->next = r;
                s = r;
            }
            r = r ->next;
            s ->next = NULL;
        }//while
    
        cnt = 1;
        s = head_new ->next = SortStcondSc(head_new ->next);
        while (s)
        {
            if (cnt > 6)
                break;
            else if (cnt == 4)
                printf("\n\t\t        ** 三等奖 **\n");
            else if (cnt == 2)
                printf("\n\t\t        ** 二等奖 **\n");
            else if (cnt == 1)
                printf("\n\n\t\t        ** 一等奖 **\n");
            cnt++;
            printf("\t\t   %s", s ->stnum);
            t = head_st;
            while (t)
            {
                if (strcmp(t ->stnum, s ->stnum) == 0)
                    printf("\t   %s\n", t ->stname);
                t = t ->next;
            }
            s = s ->next;
        }//while
        printf("\n\n       **奖学金评定完成,按Enter返回!\n");
    }//schoshipAsse
    
    //删除学生基本信息
    void deleteStudent()
    {
        char stnum[12];
        struct student *head_st, *head, *p, *q;
        head = (struct student *)malloc(sizeof(struct student));
        head ->next = head_st = loadStudent();
    
        printf("请输入要删除的学生的学号:");
        scanf("%s", stnum);
    
        p = head_st;
        q = head;
        while (p && strcmp(stnum, p ->stnum) != 0)
        {
            q = p;
            p = p ->next;
        }
        if (p)
        {
            int key;
            printf("\n 您要删除的学生信息\n");
            printf("  学号:%s\n", p ->stnum);
            printf("  姓名:%s\n", p ->stname);
            printf("\n **确定删除?\n");
            printf("  1 - 确定      0 - 取消\n");
            scanf("%d", &key);
            if (key == 1)
            {
                q ->next = p ->next;
                free(p);
                printf("\n  **删除成功!");
                fprintfStudent(head ->next);
            }
        }//if
        else
            printf("\n  **未找到,删除失败!");
        printf("\n  **按Enter返回!");
    }//deleteStudent
    
    //删除课程信息
    void deleteSubject()
    {
        char subnum[12];
        struct subject *head_sub, *head, *p, *q;
        head = (struct subject *)malloc(sizeof(struct subject));
        head ->next = head_sub = loadSubject();
    
        printf("请输入要删除的课程的课程号:");
        scanf("%s", subnum);
    
        p = head_sub;
        q = head;
        while (p && strcmp(subnum, p ->subNum) != 0)
        {
            q = p;
            p = p ->next;
        }
        if (p)
        {
            int key;
            printf("\n 您要删除的课程信息\n");
            printf("  课程号:%s\n", p ->subNum);
            printf("  课程名:%s\n", p ->subName);
            printf("\n **确定删除?\n");
            printf("  1 - 确定      0 - 取消\n");
            scanf("%d", &key);
            if (key == 1)
            {
                q ->next = p ->next;
                free(p);
                printf("\n  **删除成功!");
                fprintfsubject(head ->next);
            }
        }//if
        else
            printf("\n  **未找到,删除失败!");
        printf("\n  **按Enter返回!");
    }//deleteSubject
    
    //删除课程成绩信息
    void deleteStScore()
    {
        int t, cnt;
        char term[3];
        char stnum[12], subname[20];
        struct subject *head_sub, *r, *a[10];
        struct stscore *head_stsc, *head, *p, *q;
        head = (struct stscore *)malloc(sizeof(struct stscore));
    
        printf("请输入学期:");
        scanf("%s", term);
        t = 0 + term[0] - '0';
        r = head_sub = loadSubject();
        printf("         第%d学期课程\n", t);
        printf("   =========================\n");
        cnt = 1;
        while (r)
        {
            if (r ->term == t)
            {
                a[cnt] = r;
                printf("     %d -- %s\n", cnt++, r ->subName);
            }
            r = r ->next;
        }
        printf("     请选择:");
        scanf("%d", &t);
        strcpy(subname, a[t] ->subName);
        strcat(subname, "_");
        strcat(subname, term);
        strcat(subname, ".txt");
    
        printf("请输入要删除成绩的学生学号:");
        scanf("%s", stnum);
        head ->next = head_stsc = loadStscore(subname);
    
        p = head_stsc;
        q = head;
        while (p && strcmp(stnum, p ->stnum) != 0)
        {
            q = p;
            p = p ->next;
        }
        if (p)
        {
            int key;
            printf("\n\n 您要删除的信息\n");
            printf(" 课程名:%s\n", a[t] ->subName);
            printf(" 学号:%s\n", stnum);
            printf("\n **确定删除成绩信息?\n");
            printf("  1 - 确定      0 - 取消\n");
            scanf("%d", &key);
            if (key == 1)
            {
                q ->next = p ->next;
                free(p);
                printf("\n  **删除成功!");
                fprintfstscore(head ->next, subname);
            }
        }//if
        else
            printf("\n  **未找到,删除失败!");
        printf("\n  **按Enter返回!");
    }//deleteStScore
    
    //删除品行成绩信息
    void deleteStCondSc()
    {
        char stnum[12];
        struct stCondSc *head_st, *head, *p, *q;
        head = (struct stCondSc *)malloc(sizeof(struct stCondSc));
        head ->next = head_st = loadstCondSc();
    
        printf("请输入要删除的学生的学号:");
        scanf("%s", stnum);
    
        p = head_st;
        q = head;
        while (p && strcmp(stnum, p ->stnum) != 0)
        {
            q = p;
            p = p ->next;
        }
        if (p)
        {
            int key;
            printf("\n 您要删除的学生信息\n");
            printf("  学号:%s\n", p ->stnum);
            printf("\n **确定删除?\n");
            printf("  1 - 确定      0 - 取消\n");
            scanf("%d", &key);
            if (key == 1)
            {
                q ->next = p ->next;
                free(p);
                printf("\n  **删除成功!");
                fprintfstCondSc(head ->next);
            }
        }//if
        else
            printf("\n  **未找到,删除失败!");
        printf("\n  **按Enter返回!");
    }//deleteStCondSc
    
    //删除综合信息
    void deleteCominfo()
    {
        char stnum[12];
        struct cominfo *head_st, *head, *p, *q;
        head = (struct cominfo *)malloc(sizeof(struct cominfo));
        head ->next = head_st = loadstCominfo();
    
        printf("请输入要删除的学生的学号:");
        scanf("%s", stnum);
    
        p = head_st;
        q = head;
        while (p && strcmp(stnum, p ->stnum) != 0)
        {
            q = p;
            p = p ->next;
        }
        if (p)
        {
            int key;
            printf("\n 您要删除的学生信息\n");
            printf("  学号:%s\n", p ->stnum);
            printf("  姓名:%s\n", p ->stname);
            printf("\n **确定删除?\n");
            printf("  1 - 确定      0 - 取消\n");
            scanf("%d", &key);
            if (key == 1)
            {
                q ->next = p ->next;
                free(p);
                printf("\n  **删除成功!");
                fprintfStCominfo(head ->next);
            }
        }//if
        else
            printf("\n  **未找到,删除失败!");
        printf("\n  **按Enter返回!");
    }//deleteCominfo
    

     

    展开全文
  • C语言学生成绩管理系统源代码

    万次阅读 多人点赞 2018-03-21 20:27:20
    大学C语言实训课,C语言学生成绩管理系统。 #include<stdio.h> #include<string.h> #include<math.h> struct student { int num; char name[20]; float pingshi; float shiyan; ...

    大学C语言实训课,C语言学生成绩管理系统。

    #include<stdio.h>
    #include<string.h>
    #include<math.h>
    struct student
    	{
    		int num;
    		char name[20];
    		float pingshi;
    		float shiyan;
    		float kaoshi;
    		double zongping;
    	}stu[4];
    void main()
    {
    	void a();
    	void b();
    	void c();
    	void d();
    	void e();
    	int n;
    	while(n!=6)
    	{	printf("\t大学计算机基础成绩管理系统\n");
    		printf("1:输入一个班学生大学计算机基础成绩记录\n");
    		printf("2:显示所有成绩记录\n");
    		printf("3:计算并输出平均成绩,均方差\n");
    		printf("4:输出成绩与排名\n");
    		printf("5:结果存入文件chengji.txt\n");
    		printf("6:退出系统\n");
    		printf("输入选项代码:");
    		scanf("%d",&n);
    		switch(n)
    		{
    			case 1:a();break;
    			case 2:b();break;
    			case 3:c();break;
    			case 4:d();break;
    			case 5:e();break;
    			case 6:printf("\n*******************谢谢使用!*******************\n");break;
    			break;    
    		}	
    	}
    getchar();
    }
    /* 子  函  数*/
    void a() /* 输入一个班的学生记录*/
    
    {
    	int i;
    
    	for(i=0;i<4;i++)
    
    	{   
    
    		printf("请输入学号 姓名 平时成绩 实验成绩 考试成绩:");
    
    		scanf("%d%s%f%f%f",&stu[i].num,stu[i].name,&stu[i].pingshi,&stu[i].shiyan,&stu[i].kaoshi);
    		
    	}for(i=0;i<4;i++)
    stu[i].zongping=0.1*stu[i].pingshi+0.3*stu[i].shiyan+0.6*stu[i].kaoshi;
    }
    void b()/* 显示所有记录*/
    
    {
    	int i;
    
    	printf("学号        姓名       平时成绩       实验成绩      考试成绩     总评成绩\n");
    
    	for(i=0;i<4;i++)
    
    		printf("%d%14.2s%14.2f%14.2f%14.2f%14.2f\n",stu[i].num,stu[i].name,stu[i].pingshi,stu[i].shiyan,stu[i].kaoshi,stu[i].zongping);
    
    }
    
    void c()/* 求出全班平均成绩,显示均方差*/
    {  
    	int a[4]={0,1,2,3};
        int i,j;
        double total=0,pfc=0,bzc=0;
        double ave;
        for(i=0;i<4;i++)
    	{
    		total=total+stu[i].zongping;
    	}
        ave=total/4.0;
        printf("总评平均成绩是%f\n",ave);
    	for(i=0;i<4;i++)
    	{
    		pfc=pow((stu[i].zongping-ave),2)/4;
    	}
    	bzc=sqrt(pfc);
    	printf("\n平方差是%f\n",pfc);
    	printf("\n标准差是%f\n",bzc);
    }
    void d()
    
    {
    	int a[4]={0,1,2,3};
    	int i,j,temp;
    	for(j=0;j<3;j++)
    	{
    		for(i=0;i<3-j;i++)
    		if(stu[a[i]].zongping>stu[a[i+1]].zongping)
    		{	
    			temp=a[i];a[i]=a[i+1];
    			a[i+1]=temp;
    
    		}
    	}
    
    	printf("顺序为:\n");
    
    	printf("学号     姓名      总评成绩\n");
    
    	for(i=0;i<4;i++)
    
    		printf("%d%10.2s%15.2f\n",stu[a[i]].num,stu[a[i]].name,stu[a[i]].zongping);
    
    	printf("\n");
    
    }
    
    void e()
    {int i;
    FILE *fp;
    fp=fopen("chengji.txt","w");
    
    	fprintf(fp,"学号        姓名       平时成绩       实验成绩      考试成绩     总评成绩\n");
    
    	for(i=0;i<4;i++)
    
    		fprintf(fp,"%d%14.2s%14.2f%14.2f%14.2f%14.2f\n",stu[i].num,stu[i].name,stu[i].pingshi,stu[i].shiyan,stu[i].kaoshi,stu[i].zongping);
    
    printf("\n\n*******************恭喜,保存完成!*******************\n\n");
    }
    

    简单记录。

     

    关注微信公众号“资料在线”,回复“C语言源码”,即可获得C语言源码包

    更多资源等着你

     

    展开全文
  • C语言实现学生成绩管理系统设计

    万次阅读 多人点赞 2017-07-22 11:19:30
    本系统有**增加学生记录、修改学生记录、删除学生记录、按姓名查询学生记录、按C语言成绩对学生进行排序、退出系统**6大功能。 能够对学生的姓名,学号,c语言成绩做相应的操作。 在检测到输入成绩大于55时,会...

    本系统有**增加学生记录、修改学生记录、删除学生记录、按姓名查询学生记录、按C语言成绩对学生进行排序、退出系统**6大功能。
    能够对学生的姓名,学号,c语言成绩做相应的操作。
    在检测到输入成绩大于55时,会自动加上5。

    该管理系统设计功能模块图:

    下面是源代码:

    #include "stdio.h"  
    #include "string"
    
    /*定义学生结构体*/  
    struct Student
    {
         char ID[20];       //学号
         char Name[20];     //姓名
         float C_Mark;      //C语言成绩
    };
    
    /*声明学生数组及学生数量*/  
    struct Student students[1000];  
    int num=0;  
    
    /*通过学号返回数组下标*/   
    int Student_SearchByIndex(char id[])  
    {
        int i;  
        for (i=0;i<num;i++)  
        {
            if (strcmp(students[i].ID,id)==0)  
            {
                return i;  
            }  
        }  
        return -1;   
    }
    
    /*通过姓名返回数组下标*/
    int Student_SearchByName(char name[])  
    {
        int i;  
        for (i=0;i<num;i++)  
        { 
            if (strcmp(students[i].Name,name)==0)
            { 
                return i;
            }  
        }  
        return -1;  
    }  
    
    /*显示单条学生记录*/  
    void Student_DisplaySingle(int index)   
    {
        printf("%10s%10s%8s\n","学号","姓名","C语言成绩");  
        printf("-------------------------------------------------------------\n");  
        printf("%10s%10s%8.2f\n",students[index].ID,students[index].Name,students[index].C_Mark);  
    }  
    
    /****1、增加学生记录*****/  
    void Student_Insert()  
    {  
        while(1)  
        {
            printf("请输入学号:");  
            scanf("%s",&students[num].ID);  
            getchar();  
            printf("请输入姓名:");  
            scanf("%s",&students[num].Name);  
            getchar(); 
            printf("请输入C语言成绩:");  
            scanf("%f",&students[num].C_Mark);  
            getchar(); 
            if (54<students[num].C_Mark && students[num].C_Mark< 60)    //把55~59分之间的成绩都加上5分
            {
                students[num].C_Mark += 5;      
            }
    
            num++;
    
            printf("是否继续?(Y/N),继续请按任意键,否则输入N:"); 
            if (getchar()=='N')  
            {  
                break;
            }  
         }  
    }     
    
    /******2、修改学生信息**********/  
    void Student_Modify()  
    {  
        while(1) 
        {  
            char id[20]; 
            int index; 
            printf("请输入要修改的学生的学号:"); 
            scanf("%s",&id);  
            getchar();  
            index=Student_SearchByIndex(id);  
            if (index==-1)  
            {  
                printf("该学生不存在!\n"); 
             }
            else  
            {  
                printf("你要修改的学生信息为:\n"); 
                Student_DisplaySingle(index);  
                printf("-- 请输入新值--\n"); 
                printf("请输入学号:");  
                scanf("%s",&students[index].ID);  
                getchar();  
                printf("请输入姓名:");  
                scanf("%s",&students[index].Name);  
                getchar();  
                printf("请输入C语言成绩:");  
                scanf("%f",&students[index].C_Mark);  
                getchar();  
    
             }  
    
             printf("是否继续?(Y/N),继续请按任意键,否则输入N:"); 
             if (getchar()=='N')  
             {  
                break;
             }  
    
         }  
    
    } 
    
    /****3、删除学生信息****/  
    void Student_Delete()  
    { 
        int i;  
        while(1)  
        {  
            char id[20];  
            int index;  
            printf("请输入要删除的学生的学号:");  
            scanf("%s",&id);  
            getchar();  
            index=Student_SearchByIndex(id);  
            if (index==-1)  
            {  
                printf("学生不存在!\n");  
            }  
            else  
            {  
                printf("你要删除的学生信息为:\n"); 
                Student_DisplaySingle(index);  
                printf("是否真的要删除?(Y/N)");  
                if (getchar()=='Y')  
                {  
                    for (i=index;i<num-1;i++)  
                    {  
                        students[i]=students[i+1];//把后边的对象都向前移动  
                    } 
                    num--;  
                 }  
                getchar();  
                printf("已删除\n");
             }  
    
             printf("是否继续删除?(Y/N),继续请按任意键,否则输入N:"); 
             if (getchar()=='N')  
             {  
                break;
             }  
         }  
    }  
    
    
    /****4、按姓名查询******/  
    void Student_Select()  
    {  
        while(1)  
        {  
            char name[20];  
            int index;  
    
            printf("请输入要查询的学生的姓名:");  
            scanf("%s",&name); 
            getchar();  
            index=Student_SearchByName(name);  
    
            if (index==-1) 
            {  
                printf("学生不存在!\n"); 
            } 
            else  
            {  
                printf("你要查询的学生信息为:\n"); 
                Student_DisplaySingle(index);  
            }  
    
            printf("是否继续?(Y/N),继续请按任意键,否则输入N:"); 
            if (getchar()=='N')  
            {  
                break;
            } 
    
         }
    }  
    
    
    
    /******5、按C语言成绩排序*******/  
    void Student_SortByAverage()  
    {  
        int i,j;  
        struct Student tmp;  
    
        for (i=0;i<num;i++)  
        {  
            for (j=1;j<num-i;j++) 
            {  
                if (students[j-1].C_Mark<students[j].C_Mark) 
                {  
                    tmp=students[j-1]; 
                    students[j-1]=students[j];  
                    students[j]=tmp;  
                }  
            }  
        }  
    }  
    
    
    /*显示学生信息*/  
    void Student_Display()  
    {  
        int i;  
        printf("%10s%10s%8s\n","学号","姓名","成绩");  
        printf("-------------------------------------------------------------\n");  
    
        for (i=0;i<num;i++)  
        {  
            printf("%10s%10s%8.2f\n",students[i].ID,students[i].Name,students[i].C_Mark);  
        }  
    
    }  
    
    /*将学生信息从文件(Database.txt)中读出*/  
    void IO_ReadInfo()  
    { 
        FILE *fp;  
        int i;  
    
        if ((fp=fopen("Database.txt","rb"))==NULL)  
        {  
            printf("不能打开文件!\n");  
            return;  
        }
    
        if (fread(&num,sizeof(int),1,fp)!=1)  
        {  
            num=-1;  
        } 
        else  
        {  
            for(i=0;i<num;i++)  
            {  
                fread(&students[i],sizeof(struct Student),1,fp);  
            }  
        } 
    
        fclose(fp);  
    } 
    
    /*将学生信息写入文件(Database.txt)*/  
    void IO_WriteInfo()
    {  
        FILE *fp; 
        int i;  
        if ((fp=fopen("Database.txt","wb"))==NULL)  
        {  
            printf("不能打开文件!\n");  
            return;  
        }  
        if (fwrite(&num,sizeof(int),1,fp)!=1)  
        {  
            printf("写入文件错误!\n");  
        }  
        for (i=0;i<num;i++)  
        {  
            if (fwrite(&students[i],sizeof(struct Student),1,fp)!=1)  
            {  
                printf("写入文件错误!\n");  
            }  
        }  
        fclose(fp);  
    } 
    
    /***********主程序*********/ 
    void main()  
    { 
        int choice;  
    
        IO_ReadInfo();          //读取文件
    
        while(1)  
        {  
            /*主菜单*/  
            printf("\n------ 学生成绩管理系统------\n");  
            printf("1. 增加学生记录\n");  
            printf("2. 修改学生记录\n");  
            printf("3. 删除学生记录\n");  
            printf("4. 按姓名查询学生记录\n");  
            printf("5. 按C语言成绩排序\n");  
            printf("6. 退出\n");  
            printf("请选择(1-6):");  
    
            scanf("%d",&choice);  
            getchar();  
    
            switch(choice)  
            { 
            case 1:  
                Student_Insert();  
                break; 
    
            case 2: 
                Student_Modify(); 
                break;  
    
            case 3:  
                Student_Delete(); 
                break;  
    
            case 4:  
                Student_Select();
                break;  
    
            case 5:  
                Student_SortByAverage();
                Student_Display();
                break;  
    
            case 6: 
                exit(0);  
                break;  
            } 
            IO_WriteInfo();  
    
        } 
    }  
    

    运行结果:
    测试第一个功能,输入四个学生的成绩:

    测试第二个功能,修改学生记录:

    测试第三个功能,删除学生记录:

    测试第四个功能,按姓名查询学生记录:

    测试第五个功能,显示所有学生的成绩,按照C语言成绩由高到底排序:

    我们可以看到,各项功能的实现,在第2个步骤中,将赵的成绩改为80,而第3个步骤删除了李的成绩。从第5个步骤中可以看出,我们输入的张是56分,输出按照事先设定好的加上5变成了61分。系统的稳定正在测试中,按照原计划实现了功能。

    本系统的整个开发过程和功能实现,能够进行学生C语言成绩信息录入、修改、删除、查询、浏览操作,本系统的应用,将会使学生和教务管理人员在第一时间内获得理想的信息。

    展开全文
  • C语言学生成绩管理(文件读取和写入)

    万次阅读 多人点赞 2018-07-09 17:15:11
    # include &lt;stdio.h&gt; # include &lt;stdlib.h&gt; # include &lt;string.h&gt; # include &lt;math.h&gt; # include &lt;conio.h&gt; # define eps 1;......
  • 学生成绩管理系统-C语言(附源码)

    万次阅读 多人点赞 2019-03-23 14:57:57
    #include <stdio.h> #include <string.h> #include <stdlib.h> //结构体 struct score { char snum[9]; char sname[11]; int chinese; int math; int english;... int ra...
  • C语言成绩管理

    2013-03-29 18:32:59
     完成学生成绩管理,具体要求如下:  1.输入一个班n名学生(n30),m门课程(m8)的成绩,做成文件score.in,  要求有良好的输入界面;  2.score.in中读入该班成绩,计算出每位学生总成绩、平均成绩;  3.按...
  • C语言学生成绩管理系统

    万次阅读 多人点赞 2018-11-29 06:58:56
    C语言实现了学生成绩管理系统,可以对学生成绩进行录入、查询、修改、删除和排序。 #include &amp;amp;lt;stdio.h&amp;amp;gt; #include &amp;amp;lt;stdlib.h&amp;amp;gt; #include &amp;amp;...
  • C语言程序设计训练的大作业,已在VC6.0上测试编译运行通过,并内附设计报告,欢迎下载。这句话是为了凑字数的。
  • 利用链表,文件打开等操作实现的学生成绩管理系统。 符合多种要求。
  • C语言实现学生成绩管理系统

    万次阅读 多人点赞 2017-09-20 23:41:31
    C语言实现学生成绩管理系统V1.0某班有最多不超过30人(具体人数由键盘输入),参加某门课程的考试,实现如下学生成绩管理: 录入每个学生的学号和考试成绩 计算课程的总分和平均分 按成绩由高到低排出名次表 按学号...
  • c语言学生成绩管理系统

    热门讨论 2013-03-14 22:27:45
    一、题目: 学生成绩管理系统 二、目的与要求 1. 目的: (1)基本掌握面向过程程序设计的基本思路和方法; (2)达到熟练掌握C语言的基本知识和技能; (3)能够利用所学的基本知识和技能,解决简单的程序设计问题...
  • 设计一个学生成绩管理系统,系统功能需求: (1)输入学生的信息,包含学号、姓名、性别等基本信息和各课成绩(C语言,高等数学,线性代数); (2)显示全部学生各科成绩信息; (3)对各科成绩统计分析(总分、...
  • 打磨出一个较为完整的学生成绩管理系统 注意:本文实在文件中直接读取学生的数据 而不是手动添加 暂时没有增加添加学生的功能 后期更新(多添加一个函数的事情) 所有源代码在本文的末尾 运行环境:windows 由于...
  • C语言 项目总结】学生成绩管理系统项目概况问题与分析主要框架的确立输入缓冲区的问题文件操作感想总结 项目概况 用C语言创建一个“学生成绩管理系统”,供学生、教师、管理员、超级管理员使用,不同身份登陆者...
  • 1.可实现对学生成绩的录入、查询、增加、删除、输出基本操作 2.可对学生的成绩进行排序,按总分排序、按科目排序、按平均分排序等 3.录入学生的基本分数,可计算并输出学生的操行分,成绩等级等 4.采用了文件的读和...
  • 作者大一刚学完谭浩强C语言课程设计(第四版)之后所写,代码简单容易读,适合C语言课程设计大作业,初学,不好勿喷,我会慢慢学的
  • C语言学生成绩信息管理系统课程设计报告

    万次阅读 多人点赞 2016-10-07 22:19:22
    学生成绩管理系统 主要功能: (1)能按学期、按班级完成对学生成绩的录入、 修改,删除 (2)能按班级统计学生的成绩,求学生的总分及 平均分,并能根据学生的平均成绩进行排序 (3)能查询学生...
  • 有没有C语言的大佬可以帮助我一个问题,就是C语言读取文件
  • c语言版的学生成绩管理系统,有ppt和Word文档,分管理员账户与学生账户,代码长度1000行+;是一个完整的实验报告
  • 此乃C语言程序设计课本书作业,学生成绩管理系统 此乃C语言程序设计课本书作业,学生成绩管理系统
  • 3)学生成绩管理系统  需要处理的基础数据 学生基本信息:如班级、学号、姓名、性别、年龄等。 学生选修课程的基本信息:课程编号、课程名称、学分、考试成绩、平时成绩、综合成绩(考试成绩*0.7+平时成绩*0.3...
  • 设计一个学生信息管理系统,包括学生成绩信息数据的求和、排序、查找、模糊查找、分类统计、输出、读写文件等基本操作,要求编程实现如下菜单驱动的学生信息管理系统: (1)录入每个学生的学号、姓名、学院和各科...
  • ----------c语言程序学生成绩管理系统源代码-----------
  • C语言链表编写学生成绩管理系统

    万次阅读 多人点赞 2018-09-06 20:04:12
    一、设计题目:学生成绩管理系统 二、目的与要求 每位学生记录包含有学号、姓名、性别、出生日期、三门功课的成绩(高等数学、大学英语、C语言)、总分和平均分 系统菜单: (1)录入学生记录 (2)添加学生...
  • C语言详细学生成绩管理系统

    千次阅读 2019-03-28 16:15:13
    C语言 学生成绩管理系统 简述:该学生管理系统数据结构采用结构体 1、系统需求分析 1.1系统介绍 本学生管理系统是为教师人员提供管理班级成绩的工具,该系统可以实现的对学生的成绩进行增、删、改、查、信息保存和...

空空如也

1 2 3 4 5 ... 20
收藏数 10,321
精华内容 4,128
关键字:

c语言成绩管理

c语言 订阅