c语言实现一个(控制台程序)学生成绩管理系统(最新/完善)

学生成绩综合管理系统

这是一个初级的c综合运用,但可能存在一些未发觉BUG ,需要进行程序的压力测试才能得知,但如图所示的基本功能已经完全可以正常工作了。
在这里插入图片描述

功能

源码

  1. 输入/添加数据
  2. 查询数据
    a) 按分数查询
    b) 按分数段查询 //详见源码注释
    c) 查询已录人数
    d) 输入姓名查询
    e) 输入学号查询
    f) 查询课程成绩信息
  3. 修改数据
    a) 姓名
    b) 学号
    c) 成绩
  4. 排序输出学生信息
    a) 按姓名
    b) 按学号
    c) 按平均成绩
    d) 按课程成绩
  5. 统计
    a) 统计优秀学生
    b) 统计不及格学生
    c) 统计课程平均成绩
    d) 统计课程最高成绩
    e) 统计考试总体情况
  6. 删除
  7. 保存/导入文件 //保存/导入的路径在源码main.c旁
    a) 覆盖 //将已录入对象覆盖到已创建的文本文件
    b) 追加 //将已录入对象在文本文件末尾追加
    c) 导入 //将事先导出/编辑完成的对象导入并排序。
    d) 查看已导入文件

/***************************************************************
**
**项目名称:学生成绩管理系统
**编译环境: Code:Blocks 13.12
**调试器名称及版本: GNU gdb (GDB) 7.9.1
**作者:潮与虎
**编写时间:2020.6-17~6-21
**
***************************************************************/
#include<stdio.h>
#include<stdlib.h>   //system()函数
#include<math.h>   //fabs()函数
#include<conio.h>  //getch()函数
#include<string.h>
#define PEIN 1e-6  //对于浮点数判断相等问题的精度
struct STU
{
	char name[20];
	unsigned id;
	float mare;//math
	float enre;//english
	float chre;//Chinese
};
typedef struct node  //这是一个多指针域的单向链表
{
	struct STU stu;
	struct node* next,* sie,* rage;//next指针域按姓名顺序,si指针域按学号顺序,rage按平均分顺序。
}node;
//定义的全局变量
node* L;    //链表的头指针
node* end,* eNd,* enD;    //链表的尾指针。(end是姓名的尾指针,eNd是学号的尾指针,enD是平均分的尾指针)
 node* results[50]; //results是排序完成的指针地址。
 unsigned count_global=0;  //人数

//菜单选择项
void menu(char);
//段尾等待函数
void getcH();
//清理输入缓冲区
void cleanbuff();
//链表添加模块
void input();
//查询模块
void query();
//分类排序显示调用模块
void rank();
//课程排序算法
void class_sort(char,int);
//显示模块
void display(node **,int);
//修改模块
void alter();
//分数/分数段查询函数
int scope(float ,float,char);  //返回值是查找到的人数
//按姓名和学号精确查找对象
node *accurate_search();  //返回值是查找到的对象
//统计模块
int statistical();   //返回值没有实际意义
//文件模块
void paper();
//删除模块
int delete_node();//返回值没有实际意义

int main()
{
	char select_main, q;
	while (1)
	{
		system("cls"); //清屏
		menu('0');
		select_main = getche();
		while (select_main < 'a' || select_main>'h')
		{
			printf("无该选项!\n");
			select_main = getche();
		}
		switch (select_main)
		{
		case 'a': input(); break;//输入模块
		case 'b': query(); break;//查询模块
		case 'c': alter(); break;//修改模块
		case 'd': rank(); break;//排序模块
		case 'e':statistical();break;//统计模块
		case 'f':delete_node();break;//删除模块
		case 'g':paper();break;//文件模块
		case 'h':
			printf("确定要退出?(输入q即退出)");
			q = getche();
			if (q == 'q') return 0;
			else break;
		}
	}
	getcH();
	return 0;
}
void menu(char a)  //无bug
{
    if(a=='0')//主菜单
    {
        printf("\n\t--*-*-*-*-*-*-*---------------MENU--------------*-*-*-*-*-*-*--\n");
        printf("\t--*-*--\t\t\t\t\t\t\t--*-*--\n");
        printf("\t--*-*--\t\t请键入字母选择功能, 按h键退出:   \t--*-*--\n");
        printf("\t--*-*--\t\t\ta. 输入/添加数据\t\t--*-*--\n");
        printf("\t--*-*--\t\t\tb. 查询数据    \t\t\t--*-*--\n");
        printf("\t--*-*--\t\t\tc. 修改数据    \t\t\t--*-*--\n");
        printf("\t--*-*--\t\t\td. 排序输出学生信息\t\t--*-*--\n");
        printf("\t--*-*--\t\t\te. 统计\t\t\t\t--*-*--\n");
        printf("\t--*-*--\t\t\tf. 删除\t\t\t\t--*-*--\n");
        printf("\t--*-*--\t\t\tg. 保存/导入文件\t\t--*-*--\n");
        printf("\t--*-*--\t\t\th. 退出系统  \t\t\t--*-*--\n");
        printf("\t--*-*--\t\t\t\t\t\t\t--*-*--\n");
        printf("\t--*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*--\n\n");
    }
    else if(a=='b')//b选项子菜单
    {
        printf("\n\t--*-*-*-*-*-*-*---------Sub Menu(查询)--------*-*-*-*-*-*-*--\n");
        printf("\t--*-*--\t\t\t\t\t\t\t--*-*--\n");
        printf("\t--*-*--\t\t\ta. 按分数查询\t\t\t--*-*--\n");
        printf("\t--*-*--\t\t\tb. 按分数段查询\t\t\t--*-*--\n");
        printf("\t--*-*--\t\t\tc. 查询已录人数\t\t\t--*-*--\n");
        printf("\t--*-*--\t\t\td. 输入姓名查询\t\t\t--*-*--\n");
        printf("\t--*-*--\t\t\te. 输入学号查询\t\t\t--*-*--\n");
        printf("\t--*-*--\t\t\tf. 查询课程成绩信息\t\t--*-*--\n");
        printf("\t--*-*--\t\t\tg. 返回上一级\t\t\t--*-*--\n");
        printf("\t--*-*--\t\t\t\t\t\t\t*-*-*--\n");
        printf("\t--*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*--\n\n");
    }
    else if(a=='c')
    {
        printf("\n\t--*-*-*-*-*-*-*---------Sub Menu(修改)--------*-*-*-*-*-*-*--\n");
        printf("\t--*-*--\t\t\t\t\t\t\t--*-*--\n");
        printf("\t--*-*--\t\t\ta. 修改姓名\t\t\t--*-*--\n");
        printf("\t--*-*--\t\t\tb. 修改学号\t\t\t--*-*--\n");
        printf("\t--*-*--\t\t\tc. 修改成绩\t\t\t--*-*--\n");
        printf("\t--*-*--\t\t\td. 返回上一级\t\t\t--*-*--\n");
        printf("\t--*-*--\t\t\t\t\t\t\t--*-*--\n");
        printf("\t--*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*--\n\n");
    }
    else if(a=='d')
    {
        printf("\n\t--*-*-*-*-*-*-*---------Sub Menu(输出)--------*-*-*-*-*-*-*--\n");
        printf("\t--*-*--\t\t\t\t\t\t\t--*-*--\n");
        printf("\t--*-*--\t\t\ta. 按姓名排序输出\t\t--*-*--\n");
        printf("\t--*-*--\t\t\tb. 按学号排序输出\t\t--*-*--\n");
        printf("\t--*-*--\t\t\tc. 按平均成绩排序输出\t\t--*-*--\n");
        printf("\t--*-*--\t\t\td. 按课程成绩排序输出\t\t--*-*--\n");
        printf("\t--*-*--\t\t\te. 返回上一级\t\t\t--*-*--\n");
        printf("\t--*-*--\t\t\t\t\t\t\t--*-*--\n");
        printf("\t--*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*--\n\n");
    }
    else if(a=='e')
    {
        printf("\n\t--*-*-*-*-*-*-*---------Sub Menu(统计)--------*-*-*-*-*-*-*--\n");
        printf("\t--*-*--\t\t\t\t\t\t\t--*-*--\n");
        printf("\t--*-*--\t\t\ta. 统计优秀学生\t\t\t--*-*--\n");
        printf("\t--*-*--\t\t\tb. 统计不及格学生\t\t\t--*-*--\n");
        printf("\t--*-*--\t\t\tc. 统计课程平均成绩\t\t--*-*--\n");
        printf("\t--*-*--\t\t\td. 统计课程最高成绩\t\t--*-*--\n");
        printf("\t--*-*--\t\t\te. 统计考试总体情况\t\t--*-*--\n");
        printf("\t--*-*--\t\t\tf. 返回上一级\t\t\t--*-*--\n");
        printf("\t--*-*--\t\t\t\t\t\t\t--*-*--\n");
        printf("\t--*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*--\n\n");
    }
    else if(a=='f')
    {
        printf("\n\t\tsub menu (分数类型)\t\t\n");
        printf("\t\t\ta. 语文\t\t\t\n");
        printf("\t\t\tb. 数学\t\t\t\n");
        printf("\t\t\tc. 英语\t\t\t\n");
        printf("\t\t\td. 返回\t\t\t\n\n");
    }
    else if(a=='g')
    {
        printf("\n\t--*-*-*-*-*-*-*---------Sub Menu(文件)--------*-*-*-*-*-*-*--\n");
        printf("\t--*-*--\t\t\t\t\t\t\t--*-*--\n");
        printf("\t--*-*--\t\t\ta. 追加\t\t\t\t--*-*--\n");
        printf("\t--*-*--\t\t\tb. 覆盖\t\t\t\t--*-*--\n");
        printf("\t--*-*--\t\t\tc. 导入\t\t\t\t--*-*--\n");
        printf("\t--*-*--\t\t\td. 查看已导入的文件\t\t--*-*--\n");
        printf("\t--*-*--\t\t\te. 返回\t\t\t\t--*-*--\n");
        printf("\t--*-*--\t\t\t\t\t\t\t--*-*--\n");
        printf("\t--*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*--\n\n");
    }
    else printf("出现错误!!!");
}

void input() //  添加时建立名字、学号和分数的排序算法   无bug
{
		unsigned int size, id_temp;
		char name_temp[20];
		float e, c, m;
		node* pnew;
		printf("   请输入要新增学生数量:\n");
		scanf("%u", &size);
		cleanbuff();   //清理留下的回车符。
		while (size < 1 || size>20)
		{
			printf("输入不合理,重新输入!");
			scanf("%u", &size);
			cleanbuff();
		}
		if (count_global == 0)   //不是第一次建立,则跳过
		{
			L = (node*)malloc(sizeof(node));
			L->next = NULL;
			L->sie=NULL;
			L->rage=NULL;
			end = L;
			eNd =L;
			enD =L;
		}
		for (unsigned i = 0; i < size; count_global++, i++)  //count_global计数器在这里
		{
			printf("请分别输入学生的姓名、学号,语文、数学、英语的百分制分数(以空格分割)\n");
			scanf("%s%u%f%f%f", name_temp, &id_temp, &c, &m, &e);
			cleanbuff();
			while ((m < 0 || m>100) || (e < 0 || e>100) || (c < 0 || c>100))
			{
				printf("分数似乎不是百分制?");
				scanf("%s%u%f%f%f", name_temp, &id_temp, &c, &m, &e);
				cleanbuff();
			}
			pnew = (node*)malloc(sizeof(node));
			strcpy(pnew->stu.name, name_temp);
			pnew->stu.id = id_temp;
			pnew->stu.mare = m;
			pnew->stu.chre = c;
			pnew->stu.enre = e;
			if (count_global == 0)//尾插法
			{
				pnew->next = end->next;
				pnew->sie=eNd->sie;
				pnew->rage=enD->rage;//
				end->next = pnew;
				eNd->sie=pnew;
				enD->rage=pnew;
				end = pnew;  //三个指针的含义不同,所以要分别赋值
				eNd = pnew;
				enD =pnew;
			}
			else
            {  //姓名排序算法
                if (strcmp(pnew->stu.name, (L->next)->stu.name) < 0)//头插法
				{
					pnew->next = L->next;
					L->next = pnew;
				}
				else if (strcmp(pnew->stu.name, end->stu.name) >= 0)//尾插法
				{
					pnew->next = end->next;
					end->next = pnew;
					end = pnew;
				}
				else
                {
                    node* after = L->next, * before = after->next;  //搜索指针。按姓名排列。
                    while (1)
                    {
                        if (strcmp(after->stu.name, pnew->stu.name) <= 0 && strcmp(pnew->stu.name, before->stu.name) <= 0)  //中间插法
                        {
                            after->next = pnew;
                            pnew->next = before;
                            break;
                        }
                        after = after->next;
                        before = before->next;
                        if (before == NULL)//尾插法
                        {
                            pnew->next = end->next;
                            end->next = pnew;
                            end = pnew;
                            break;
                        }
                    }
				}   //姓名排序完成,开始学号排序。
				if (pnew->stu.id<(L->sie)->stu.id)//头插法
				{
					pnew->sie = L->sie;
					L->sie = pnew;
				}
				else if (pnew->stu.id>=eNd->stu.id)//尾插法
				{
					pnew->sie = eNd->sie;
					eNd->sie = pnew;
					eNd = pnew;
				}
				else
                {
                    node* after = L->sie, * before = after->sie;//搜索指针。按学号排列。
                    while (1)
                    {
                        if (pnew->stu.id >= after->stu.id && pnew->stu.id <= before->stu.id)  //中间插法
                        {
                            after->sie = pnew;
                            pnew->sie = before;
                            break;
                        }
                        after = after->sie;
                        before = before->sie;
                        if (before == NULL)//尾插法
                        {
                            pnew->sie = eNd->sie;
                            eNd->sie = pnew;
                            eNd = pnew;
                            break;
                        }
                    } //学号排序完成,开始分数排序。
                }
                if ((pnew->stu.enre)+(pnew->stu.chre)+(pnew->stu.mare)<((L->rage)->stu.enre)+((L->rage)->stu.mare)+((L->rage)->stu.chre))//头插法
                {
                    pnew->rage = L->rage;
                    L->rage = pnew;
                }
                else if ((pnew->stu.enre)+(pnew->stu.chre)+(pnew->stu.mare)>=(enD->stu.enre)+(enD->stu.mare)+(enD->stu.chre))//尾插法
                {
                    pnew->rage = enD->rage;
                    enD->rage = pnew;
                    enD = pnew;
                }
                else
                {
                    node* after = L->rage, * before = after->rage;   //搜索指针。按分数排列。
                    while (1)
                    {
                        if (((pnew->stu.enre)+(pnew->stu.chre)+(pnew->stu.mare)>=(after->stu.enre)+(after->stu.mare)+(after->stu.chre)) && ((pnew->stu.enre)+(pnew->stu.chre)+(pnew->stu.mare)<=(before->stu.enre)+(before->stu.mare)+(before->stu.chre))) //中间插法
                        {
                            after->rage = pnew;
                            pnew->rage = before;
                            break;
                        }
                        after = after->rage;
                        before = before->rage;
                        if (before == NULL)//尾插法
                        {
                            pnew->rage = enD->rage;
                            enD->rage = pnew;
                            enD = pnew;
                            break;
                        }
                    }
                }
            }
		}
		printf("添加完成,我将返回(任意击建继续.......)");
		getcH();
}

void rank()   //分类排序显示调用    无bug
{
    char selec;
    node*qt;   //传递的标志位qt
    qt= (node*)malloc(sizeof(node));
	while (1)
	{
	    if (count_global==0)
        {
            printf("您还未录入成员!!!\n");
            break;
        }
		system("cls"); //清屏
		menu('d');
		selec = getche();
		while (selec < 'a' || selec>'e')
		{
			printf("无该选项!\n");
			selec = getche();
		}
		if(selec=='a')//姓名
        {
            qt->stu.id=1;
            display(&qt,0);   //已经排列完成
            free(qt);
        }
        else if(selec=='b')//学号
        {
            qt->stu.id=2;
            display(&qt,0);
            free(qt);
        }
        else if(selec=='c')//平均
        {
            qt->stu.id=3;
            display(&qt,0);
            free(qt);
        }
        else if(selec=='d')//课程
        {
            char selecp;
            while (1)
            {
                system("cls"); //清屏
                menu('f');
                selecp = getche();
                while (selecp < 'a' || selecp>'d')
                {
                    printf("无该选项!\n");
                    selecp = getche();
                }
                printf("\n");
                if(selecp=='a')
                {
                    class_sort('a',count_global);
                    for(int jja=0; (*( results+jja ))!=NULL ;jja ++)
                        printf("姓名:%-*s 学号:%-11d 语文:%-5.2f\n",19,(*( results+jja ))->stu.name,(*( results+jja ))->stu.id,(*( results+jja ))->stu.chre);
                    printf("\n我已完成,任意击键继续.......");
                    getcH();
                }
                else if(selecp=='b')
                {
                    class_sort('b',count_global);
                    for(int jjj=0; (*( results+jjj ))!=NULL ;jjj ++)
                        printf("姓名:%-*s 学号:%-11d 数学:%-5.2f\n",19,(*( results+jjj ))->stu.name,(*( results+jjj ))->stu.id,(*( results+jjj ))->stu.mare);
                    printf("\n我已完成,任意击键继续.......");
                    getcH();
                }
                else if(selecp=='c')
                {
                    class_sort('c',count_global);
                    for(int jcc=0; (*( results+jcc ))!=NULL ;jcc ++)
                        printf("姓名:%-*s 学号:%-11d 英语:%-5.2f\n",19,(*( results+jcc ))->stu.name,(*( results+jcc ))->stu.id,(*( results+jcc ))->stu.enre);
                    printf("\n我已完成,任意击键继续.......");
                    getcH();
                }
                else break;
            }
        }
        else return NULL;//selec=='e'
	}
	getcH();
	return NULL;
}

void class_sort(char choose,int j)  //课程排序算法  j是要排序的最大人数   无bug*
{
    node* hunt,* beggest,* second_big;//beggest是最大分值的链表节点、搜索指针hunt每次查找除beggest最大的分值、然后送给beggest。
    int i=0 ;
    if(choose=='a')//语文的排序
    {
        hunt=L->next;
        beggest=L->next;
        while((hunt=hunt->next)!=NULL)//给beggest赋值
        {
            if((hunt->stu.chre - beggest->stu.chre) >PEIN )
                beggest=hunt;
        }
        results[i++]=beggest;
        for(; j>1 ; j--)  //j>1是因为已经存了一个数。
        {
            int count;//计数器
            hunt=L;
            second_big=L->next;
            while((hunt=hunt->next)!=NULL)//通过循环找到小于beggest之外最大分值的地址。
            {
                count=0;
                if(hunt->stu.chre < beggest->stu.chre+PEIN) //用作差法判断是否大于、
                {
                    for(int j=0; (*( results+j ))!=NULL ;j ++)  //遍历已经保存的地址是否收录了该地址。防止出现分数一样,而未被收录
                    {
                        if(hunt==(*( results+j )) )//如果该地址被收录,则计数器加一。
                            count++;
                    }
                    if(count==0)//地址未被收录这可以将中国地址作为第二大分值、进行刷新。
                        if( !((second_big->stu.chre - hunt->stu.chre)>PEIN) )//如果是第二大,则收录该地址hunt->stu.mare > ((second_big->stu.mare)-PEIN)
                            second_big=hunt;
                }
            }
            beggest=second_big;
            results[i++]=second_big;
        }
    }
    else if(choose=='b')//数学
    {
        hunt=L->next;
        beggest=L->next;
        while((hunt=hunt->next)!=NULL)//给beggest赋值
        {
            if(hunt->stu.mare > (beggest->stu.mare-PEIN))
                beggest=hunt;
        }
        results[i++]=beggest;
        for(; j>1 ; j--)//j>1是因为已经存了一个数。
        {
            int count=0;//计数器
            hunt=L;
            second_big=L->next;
            while((hunt=hunt->next)!=NULL)//通过循环找到小于beggest之外最大分值的地址。
            {
                count=0;
                if(hunt->stu.mare < (beggest->stu.mare+PEIN))//用作差法判断是否大于、
                {
                    for(int j=0; (*( results+j ))!=NULL ;j ++)  //遍历已经保存的地址是否收录了该地址。
                    {
                        if(hunt==(*( results+j )) )//如果该地址被收录,则计数器加一。
                            count++;
                    }
                    if(count==0)//地址未被收录这可以将中国地址作为第二大分值、进行刷新。
                        if(hunt->stu.mare > ((second_big->stu.mare)-PEIN))//如果是第二大,则收录该地址
                            second_big=hunt;
                }
            }
            beggest=second_big;
            results[i++]=beggest;
        }
    }
    else  //英语
    {
        hunt=L->next;
        beggest=L->next;
        while((hunt=hunt->next)!=NULL)//给beggest赋值
        {
            if(hunt->stu.enre > (beggest->stu.enre-PEIN))
                beggest=hunt;
        }
        results[i++]=beggest;
        for(; j>1 ; j--)//j>1是因为已经存了一个数。
        {
            int count=0;//计数器
            hunt=L;
            second_big=L->next;
            while((hunt=hunt->next)!=NULL)//通过循环找到小于beggest之外最大分值的地址。
            {
                count=0;
                if(hunt->stu.enre < (beggest->stu.enre+PEIN))//用作差法判断是否大于、hunt->stu.mare < (beggest->stu.mare+PEIN)    (( beggest->stu.chre - hunt->stu.chre ) > PEIN)
                {
                    for(int j=0; (*( results+j ))!=NULL ;j ++)  //遍历已经保存的地址是否收录了该地址。
                    {
                        if(hunt==(*( results+j )) )//如果该地址被收录,则计数器加一。
                            count++;
                    }
                    if(count==0)//地址未被收录这可以将中国地址作为第二大分值、进行刷新。
                        if(hunt->stu.enre > ((second_big->stu.enre)-PEIN))//如果是第二大,则收录该地址
                            second_big=hunt;
                }
            }
            beggest=second_big;
            results[i++]=beggest;
        }
    }
}

void display(node** place,int i)  //打印程序   无bug
{
	if (i == 0)  //全部显示
	{
		printf("\n");
		node* temp = L;
		int i=0;  //名次标志变量
		if (L ->next== NULL)
			printf("您还未录入成员!!!\n");
		else if ((*place)->stu.id==1) //姓名排列输出
			while ((temp = temp->next)!=NULL)
			{
				printf("姓名:%-*s   学号:%-11u   语文:%5.2f  数学:%5.2f  英语:%5.2f \n", 19, temp->stu.name, temp->stu.id, temp->stu.chre, temp->stu.mare, temp->stu.enre);
			}
        else if ((*place)->stu.id==2) //学号排列输出
            while ((temp = temp->sie)!=NULL)
			{
				printf("姓名:%-*s   学号:%-11u   语文:%4.2f   数学:%4.2f   英语:%4.2f \n", 19, temp->stu.name, temp->stu.id, temp->stu.chre, temp->stu.mare, temp->stu.enre);
			}
        else if((*place)->stu.id==3)
            while ((temp = temp->rage)!=NULL)
			{
				printf("排名:%-3d  姓名:%-*s   学号:%-11u   语文:%5.2f  数学:%5.2f  英语:%5.2f  平均分:%5.2f \n", ++i,19, temp->stu.name, temp->stu.id, temp->stu.chre, temp->stu.mare, temp->stu.enre,((temp->stu.enre)+(temp->stu.chre)+(temp->stu.mare))/3.0);
			}
	}
	else if (i != 1)//因为在上面加了二所以这里传过来的数不可能等于1,然后我就这样干了
	{
	    printf("\n");
		if (i == 2) printf("没有在这个分段的同学!!\n");
		else
			for (int mm = 0; mm < i - 2; mm++)
				printf("姓名:%-*s   学号:%-11u  语文:%5.2f  数学:%5.2f  英语:%5.2f  \n", 19, (*(place + mm))->stu.name, (*(place + mm))->stu.id, (*(place + mm))->stu.chre, (*(place + mm))->stu.mare, (*(place + mm))->stu.enre);
	}
	else  //显示对应的节点数据(满足else的条件的i==1)
		printf("姓名:%-*s\n学号:%-11u\n语文:%5.2f\n数学:%5.2f\n英语:%5.2f\n\n", 19, (*place)->stu.name, (*place)->stu.id, (*place)->stu.chre, (*place)->stu.mare, (*place)->stu.enre);
	printf("我以完成即将返回,任意击键继续.......\n");
	getcH();
}

void query()  //   查询函数  无bug
{
	if (count_global==0)
    {
        printf("您还未录入成员!!!\n");
		getcH();
    }
	else
	{
		char selec;
        while (1)
        {
            system("cls"); //清屏
            menu('b');
            selec = getche();
            while (selec < 'a' || selec>'g')
            {
                printf("无该选项!\n");
                selec = getche();
            }
            if (selec == 'a')  //分数
            {
                while (1)
                {
                    char elem;
                    float sore;
                    system("cls"); //清屏
                    menu('f');    //调用课程栏-子菜单
                    elem = getche();
                    while (elem < 'a' || elem>'d')
                    {
                        printf("无该选项!\n");
                        elem = getche();
                    }
                    if (elem=='d') break;
                    printf("  输入要查询的分数:");
                    scanf("%f", &sore);
                    cleanbuff();
                    while (sore < 0 || sore>100)
                    {
                        printf("分数似乎不是百分制?");
                        scanf("%f", &sore);
                        cleanbuff();
                    }
                    scope(200, sore,elem);
                }
            }
            else if (selec == 'b')  //分数段
            {
                while (1)
                {
                    char elen;
                    float asore,fsore,tmp;
                    system("cls"); //清屏
                    menu('f');    //调用分数栏子菜单
                    elen = getche();
                    while (elen < 'a' || elen>'d')
                    {
                        printf("无该选项!\n");
                        elen = getche();
                    }
                    if (elen=='d') break;
                    printf("   输入要查询的分数段:(例:88.5 100  空格分隔)      ");
                    scanf("%f%f", &asore,&fsore);
                    cleanbuff();
                    while ((asore < 0 || asore>100) && (fsore < 0 || fsore>100))
                    {
                        printf("分数似乎不是百分制?");
                        scanf("%f%f", &asore,&fsore);
                        cleanbuff();
                    }
                    if(asore>fsore)   //防止输入出现逻辑错误  为使asore小于fsore。
                    {
                        tmp=asore;
                        asore=fsore;
                        fsore=tmp;
                    }
                    scope(asore, fsore,elen);
                }
            }
            else if (selec == 'c')   //人数查询
            {
                printf("当前已录入%3u  人...任意击键继续........",count_global);
                getcH();
            }
            else if (selec == 'd')//姓名
            {
                node* find = L->next;
                printf("输入这个名字:");
                char na[20];
                scanf("%s", na);
                cleanbuff();
                while (strcmp(find->stu.name, na)) /*查找到名字所在的节点*/
                {
                    find = find->next;
                    if(find==NULL)  break;  //防止程序运行到最后没有找到该人,导致无法访问内存使程序崩溃的bug
                }
                display(&find, 1);
            }
            else if (selec == 'e')//学号
            {
                node* find = L->next;
                unsigned id_temp;
                printf("输入这个学号:");
                scanf("%u", &id_temp);
                cleanbuff();
                while (find->stu.id != id_temp)/*查找到学号所在的节点*/
                {
                    find = find->next;
                    if(find==NULL)  break;  //防止程序运行到最后没有找到该人,导致无法访问内存使程序崩溃的bug
                }
                if(find!=NULL)  display(&find, 1);
                else
                    {
                        printf("在已输入列表没有找到这个学号!!!\n");
                        getcH();
                    }
            }
            else if (selec == 'f')//课程成绩
            {
                char selecp;
                while (1)
                {
                    system("cls"); //清屏
                    menu('f');
                    selecp = getche();
                    while (selecp < 'a' || selecp>'d')
                    {
                        printf("无该选项!\n");
                        selecp = getche();
                    }
                    printf("\n");
                    if(selecp=='a')
                    {
                        class_sort('a',count_global);
                        for(int j=0; (*( results+j ))!=NULL ;j ++)
                            printf("姓名:%-*s 学号:%-11d 语文:%-5.2f\n",19,(*( results+j ))->stu.name,(*( results+j ))->stu.id,(*( results+j ))->stu.chre);
                        printf("\n我已完成,任意击键继续.......");
                        getcH();
                    }
                    else if(selecp=='b')
                    {
                        class_sort('b',count_global);
                        for(int j=0; (*( results+j ))!=NULL ;j ++)
                            printf("姓名:%-*s 学号:%-11d 数学:%-5.2f\n",19,(*( results+j ))->stu.name,(*( results+j ))->stu.id,(*( results+j ))->stu.mare);
                        printf("\n我已完成,任意击键继续.......");
                        getcH();
                    }
                    else if(selecp=='c')
                    {
                        class_sort('c',count_global);
                        for(int j=0; (*( results+j ))!=NULL ;j ++)
                            printf("姓名:%-*s 学号:%-11d 英语:%-5.2f\n",19,(*( results+j ))->stu.name,(*( results+j ))->stu.id,(*( results+j ))->stu.enre);
                        printf("\n我已完成,任意击键继续.......");
                        getcH();
                    }
                    else break;
                }
            }
            else if(selec == 'g')//返回上一级
                break;
        }
    }
}

int scope(float asore, float fsore, char tye)//分数/分数段查询函数  无bug
{
    node* find[20];
    find[0] = NULL;
    if (asore >100)  //分数查询
    {
        if (tye == 'a')  //语文分数查询
        {
            node* markb = L;
            int i = 0;
            while ((markb = markb->next) != NULL)  /*查找到语文分数所在的所有节点*/
            {
                if (fabs(markb->stu.chre - fsore) < PEIN)
                    find[i++] = markb;
            }
            if (find[0] == NULL) display(NULL, 2);
            else display(find, i = i + 2);
        }
        else if (tye == 'b')    //数学分数查询
        {
            node* markb = L;
            int i = 0;
            while ((markb = markb->next) != NULL)  /*查找到数学分数所在的所有节点*/
            {
                if (fabs(markb->stu.mare - fsore) < PEIN)
                    find[i++] = markb;
            }
            if (find[0] == NULL) display(NULL, 2);
            else display(find, i = i + 2);
        }
        else  //英语分数查询
        {
            node* markb = L;
            int i = 0;
            while ((markb = markb->next) != NULL)  /*查找到英语分数所在的所有节点*/
            {
                if (fabs(markb->stu.enre - fsore) < PEIN)
                    find[i++] = markb;
            }
            if (find[0] == NULL) display(NULL, 2);
            else display(find, i = i + 2);
        }
    }
    else  //分数段查询
    {
        if (tye == 'a'|| tye=='A')  //语文分数段查询
        {
            node* mark = L;
            int i = 0;
            while ((mark = mark->next) != NULL)/*查找到语文分数段内的所有节点*/
            {
                if ((mark->stu.chre >= (asore - PEIN)) && (mark->stu.chre <= (fsore + PEIN)))
                    find[i++] = mark;
            }
            if(tye=='a')
            {
                if (find[0] == NULL) display(NULL, 2);
                else display(find, i = i + 2);
            }
            else   return i;
        }
        else if (tye == 'b'||tye=='B')  //数学分数段查询
        {
            node* mark = L;
            int i = 0;
            while ((mark = mark->next) != NULL)/*查找到数学分数段内的所有节点*/
            {
                if ((mark->stu.mare >= (asore - PEIN)) && (mark->stu.mare <= (fsore + PEIN)))
                    find[i++] = mark;
            }
            if(tye=='b')
            {
                if (find[0] == NULL) display(NULL, 2);
                else display(find, i = i + 2);
            }
            else   return i;
        }
        else  //英语分数段查询
        {
            node* mark = L;
            int i = 0;
            while ((mark = mark->next) != NULL)/*查找到英语分数段内的所有节点*/
            {
                if ((mark->stu.enre >= (asore - PEIN)) && (mark->stu.enre <= (fsore + PEIN)))
                    find[i++] = mark;
            }
            if(tye=='c')
            {
                if (find[0] == NULL) display(NULL, 2);
                else display(find, i = i + 2);
            }
            else   return i;
        }
    }
    return 0;
}

void getcH()  //防止出现异常或警告  无bug
{
    char tmp;
    tmp=getch();
    if(tmp);
}

void cleanbuff()  //防止系统因输入缓冲区问题出现闪屏效果。  无bug
{
    scanf("%*[^\n]%*c");
}

void alter()  //修改模块  无bug
{
	if (count_global==0)
	{
		printf("您还未录入成员!!!\n");
		getcH();
	}
	else
	{
		char select_alter, replace[20]; // replace是替换的结果、select_alter选择项变量。
		unsigned t_id;
		float sore_re;   //修改的结果(分数)
		node *find_real;
		OUT_PA:  //goto标号
		while (1)
		{
			system("cls"); //清屏
			menu('c');
			select_alter = getche();
			while (select_alter < 'a' || select_alter>'d')
			{
				printf("无该选项!\n");
				select_alter = getche();
			}
			if(select_alter=='d') break;  //操作者选择了返回
            find_real=accurate_search();//调用精确查找函数
            if(find_real!=NULL)
            {
                printf("\n你要修改的对象为:\n姓名:%-*s\n学号:%-11u\n语文:%-5.2f\n数学:%-5.2f\n英语:%-5.2f\n", 19,find_real->stu.name,find_real->stu.id,find_real->stu.chre, find_real->stu.mare, find_real->stu.enre);
                printf("是否继续?(按+继续)");/*上面的打印为什么不调用显示函数display(),是因为我在显示函数里加了gecH(),这里不需要等待*/
                char ENter; ENter=getche();//注意修改
                cleanbuff();
                if ( ENter!='+' )  goto OUT_PA;   //判断是否继续修改

                if (select_alter == 'a')
                {
                    printf("   输入你要修改为的名字:");
                    scanf("%s", replace);
                    cleanbuff();
                    strcpy(find_real->stu.name, replace);
                    printf("你将其修改为了:\n");
                    display(&find_real,1);
                }
                else if (select_alter == 'b')
                {
                    printf("   输入你要修改为的学号:");
                    scanf("%u", &t_id);
                    cleanbuff();
                    find_real->stu.id = t_id;
                    printf("你将其修改为了:\n");
                    display(&find_real,1);
                }
                else if (select_alter == 'c')//修改成绩
                {
                    char sele;
                    system("cls"); //清屏
                    menu('f');
                    sele = getche();
                    while (sele < 'a' || sele>'d')
                    {
                        printf("无该选项!\n");
                        sele = getche();
                    }
                    if(sele!='d')
                    {
                        printf("   输入你要修改为的分数:");
                        scanf("%f", &sore_re);
                    }
                    if (sele == 'a') find_real->stu.chre = sore_re;
                    else if (sele == 'b') find_real->stu.mare = sore_re;
                    else if (sele == 'c') find_real->stu.enre = sore_re;
                    else goto OUT_PA;  //跳出分数界面
                    printf("你将其修改为了:\n");
                    display(&find_real,1);
                }
            }
            else  //没有找到人,没有执行修改
            {
                printf("\n抱歉没有找到那位同学!!!任意击键继续........");
                getcH();
            }
		}
	}
}

node* accurate_search()  //根据姓名和学号精确查找对象。  无bug
{
	char name_tmp[20], row; //name_tmp是修改的对象、row判断变量。
	unsigned id_tmp;
	node* find_a[10], * find_b[10], * find_ = NULL, * mark_alter;  //find_a存姓名节点、find_b存学号节点、find_是最终节点、mark_alter是搜索指针
    find_a[0] = NULL;
    find_b[0] = NULL;
	printf("\n\t请输入你要修改/删除对象的已输入特征-姓名 学号-(空格分隔):");
	scanf("%s%u", name_tmp, &id_tmp);
	cleanbuff();
	mark_alter = L;
	int i_a = 0, i_b = 0;  //找到几个节点,对应的值就为几
	while ((mark_alter = mark_alter->next) != NULL)  /*查找到姓名所在的所有节点*/
	{
		if (0 == strcmp(mark_alter->stu.name, name_tmp))
			find_a[i_a++] = mark_alter;
	}
	mark_alter = L;
	while ((mark_alter = mark_alter->next) != NULL)  /*查找到学号所在的所有节点*/
	{
		if (mark_alter->stu.id == id_tmp)
			find_b[i_b++] = mark_alter;
	}
	/*若存在两个以上地址,则查找相同地址*/
	if ((i_a > 1 && i_b > 1)||(i_a>=1&&i_b>1)||(i_a>1&&i_b>=1))
	{
		for (int n = 0; n < i_a; n++)
			for (int m = 0; m < i_b; m++)
				if (find_a[m] == find_b[n])
					find_ = find_a[m];
	}
	else if (i_a == 1 && i_b == 1 && find_a[0] != NULL && find_a[0] != NULL) //存在两个节点的地址
	{
		if (find_a[0] == find_b[0]) find_ = find_a[0];    //这两个地址为同一个节点
		else   //如果这是两个地址不是同一个人,就让操作者判断修改谁。
		{
			printf("找到了,你输入的是两位同学分别的姓名和学号,a or b ?\n\n");
			printf("a:  姓名:%-*s   学号:%11u   语文:%5.2f  数学:%5.2f  英语:%5.2f \n", 19, find_a[0]->stu.name, find_a[0]->stu.id, find_a[0]->stu.chre, find_a[0]->stu.mare, find_a[0]->stu.enre);
			printf("b:  姓名:%-*s   学号:%11u   语文:%5.2f  数学:%5.2f  英语:%5.2f \n", 19, find_b[0]->stu.name, find_b[0]->stu.id, find_b[0]->stu.chre, find_b[0]->stu.mare, find_b[0]->stu.enre);
			row = getche();
			while (row != 'a' && row != 'b')
			{
				printf("\na or b!!");
				row = getche();
			}
			if (row == 'a') find_ = find_a[0];
			else find_ = find_b[0];
		}
	}
	else if ((i_a == 1 && i_b == 0) || (i_a == 0 && i_b == 1)) //有一项操作者没有输入正确
	{
		if (i_a == 1)   find_ = find_a[0];
		else find_ = find_b[0];
	}
	else if (find_a[0] == NULL && find_b[0] == NULL)  find_ = NULL;
	return find_;//返回最终查找到的节点地址值
}

int statistical()//统计模块  无bug
{
    if (count_global==0)
	{
		printf("您还未录入成员!!!\n");
		getcH();
		return 0;
	}
    char select_stati;
    RETU_STA:
	while (1)
	{
		system("cls"); //清屏
		menu('e');
		select_stati = getche();
		while (select_stati < 'a' || select_stati>'f')
		{
			printf("无该选项!\n");
			select_stati = getche();
		}
		if(select_stati=='a')//  优秀
        {
            char select_a;
            while (1)
            {
                system("cls"); //清屏
                menu('f');
                select_a = getche();
                while (select_a < 'a' || select_a>'d')
                {
                    printf("无该选项!\n");
                    select_a = getche();
                }
                switch(select_a)
                {
                    case 'a':printf("\n您选择的是语文分值优秀的同学\n");break;
                    case 'b':printf("\n您选择的是数学分值优秀的同学\n");break;
                    case 'c':printf("\n您选择的是英语分值优秀的同学\n");break;
                    case 'd':goto RETU_STA;
                }
                scope(80,100,select_a);
            }
        }
        else if(select_stati=='b')//  不及格
        {
             char select_b;
            while (1)
            {
                system("cls"); //清屏
                menu('f');
                select_b = getche();
                while (select_b < 'a' || select_b>'d')
                {
                    printf("无该选项!\n");
                    select_b = getche();
                }
                switch(select_b)
                {
                    case 'a':printf("\n您选择的是语文分值不及格的同学\n");break;
                    case 'b':printf("\n您选择的是数学分值不及格的同学\n");break;
                    case 'c':printf("\n您选择的是英语分值不及格的同学\n");break;
                    case 'd':goto RETU_STA;
                }
                scope(0,60-2*PEIN,select_b);
            }
        }
        else if(select_stati=='c')//  平均
        {
            float chtmp = 0, matmp = 0, entmp = 0;
            node* search_stati = L;
            float peonumb = (float)count_global;
            while ((search_stati = search_stati->next) != NULL)
            {
                chtmp += search_stati->stu.chre;
                matmp += search_stati->stu.mare;
                entmp += search_stati->stu.enre;
            }
            printf("\n语文平均分:%-5.2f 数学平均分:%-5.2f 英语平均分:%-5.2f\n\n我已完成即将返回....", chtmp / peonumb, matmp / peonumb, entmp / peonumb);
            getcH();
        }
        else if(select_stati=='d')//   最高
        {
            node *search_stati=L,*mamax=L->next,* chmax=L->next,*enmax=L->next;
            while((search_stati=search_stati->next)!=NULL)//给beggest赋值
            {
                if((search_stati->stu.chre - chmax->stu.chre) >PEIN )
                    chmax=search_stati;
                if((search_stati->stu.mare - mamax->stu.mare) >PEIN )
                    mamax=search_stati;
                if((search_stati->stu.enre - enmax->stu.enre) >PEIN )
                    enmax=search_stati;
            }
            printf("\n语文最高分:%-5.2f 数学最高分:%-5.2f 英语最高分:%-5.2f\n\n我已完成即将返回....",chmax->stu.chre,mamax->stu.mare,enmax->stu.enre);
            getcH();
        }
        else if(select_stati=='e')//总体情况
        {
            float chtmp=0,matmp=0,entmp=0;
            node *search_stati=L,*mamax=L->next,* chmax=L->next,*enmax=L->next,*mamin=L->next,* chmin=L->next,*enmin=L->next;
            float peonumb=(float)count_global;
            while((search_stati=search_stati->next)!=NULL)
            {
                chtmp+=search_stati->stu.chre;
                matmp+=search_stati->stu.mare;
                entmp+=search_stati->stu.enre;
            }
            printf("\n语文平均分:%-6.2f 数学平均分:%-6.2f 英语平均分:%-6.2f\n",chtmp/peonumb,matmp/peonumb,entmp/peonumb);

            search_stati=L;
            while((search_stati=search_stati->next)!=NULL)//给beggest赋值
            {
                if((search_stati->stu.chre - chmax->stu.chre) >PEIN )
                    chmax=search_stati;
                if((search_stati->stu.mare - mamax->stu.mare) >PEIN )
                    mamax=search_stati;
                if((search_stati->stu.enre - enmax->stu.enre) >PEIN )
                    enmax=search_stati;
            }
            printf("\n语文最高分:%-6.2f 数学最高分:%-6.2f 英语最高分:%-6.2f\n",chmax->stu.chre,mamax->stu.mare,enmax->stu.enre);

            search_stati=L;
            while((search_stati=search_stati->next)!=NULL)//给beggest赋值
            {
                if((chmin->stu.chre - search_stati->stu.chre) >PEIN )
                    chmin=search_stati;
                if((mamin->stu.mare - search_stati->stu.mare) >PEIN )
                    mamin=search_stati;
                if((enmin->stu.enre - search_stati->stu.enre) >PEIN )
                    enmin=search_stati;
            }
            printf("\n语文最低分:%-6.2f 数学最低分:%-6.2f 英语最低分:%-6.2f\n",chmin->stu.chre,mamin->stu.mare,enmin->stu.enre);
            printf("\n语文优秀人数:%-4d语文不及格人数:%-4d\n",scope(80,100,'A'),scope(0,60-2*PEIN,'A'));
            printf("\n数学优秀人数:%-4d数学不及格人数:%-4d\n",scope(80,100,'B'),scope(0,60-2*PEIN,'B'));
            printf("\n英语优秀人数:%-4d英语不及格人数:%-4d\n",scope(80,100,'C'),scope(0,60-2*PEIN,'C'));
            printf("\n我以完成、即将返回.......任意击键继续......");
            getcH();
        }
        else return 0;//==f就退出
	}
}

void paper()//文件模块   无bug
{
    static int counter=0,tu=0;//计数器-counter:如果第一次使用文件,将提示使用方法。计数器-tu:记录二维数组tmp_paper的使用情况。
    char select_paper, Path[30];
    static char tmp_paper[10][30];//防止多次导入同一个文件。
    int tmp_paper_counter;//记录导入文件的重复性
    FILE* filp;
    node* object;
RETU_FILP:
    while (1)
    {
        system("cls"); //清屏
        menu('g');
        select_paper = getche();
        while (select_paper < 'a' || select_paper>'e')
        {
            printf("无该选项!\n");
            select_paper = getche();
        }
        if(select_paper!='d'&&select_paper!='e')//仅在第一次需要输入文件名的时候提示
        {
            if(counter==0)
            printf("\n\t\"重要提示:请在每次输入文件名的时候在其末尾加上其文本格式(txt)!!!\"\n\t\t\t\"默认文件路径在main.c旁\"\n");
            counter++;
        }
        if (select_paper == 'a' || select_paper == 'b')//追加,覆盖
        {
            if (count_global==0)
            {
                printf("您还未录入成员!!!我将返回.....\n");
                getcH();
                break;
            }
            printf("\n请输入要保存的文件名:");
            scanf("%s", Path);
            cleanbuff();
RETU_PAPER:
            if (select_paper == 'a')
                filp = fopen(Path, "a+");
            else filp = fopen(Path, "w+");
            if (NULL == filp)
            {
                printf("\n文件打开失败!!!重新输入文件名:");
                scanf("%s", Path);
                cleanbuff();
                goto RETU_PAPER;
            }
            object = L;
            while ((object = object->next) != NULL)
            {
                if (fprintf(filp, "%s %u %f %f %f\n",object->stu.name, object->stu.id,object->stu.chre,object->stu.mare,object->stu.enre) < 0)//写入失败返回负数
                {
                    printf("\n写入数据错误!!\n");
                    break;
                }
            }
            fclose(filp);
            printf("学生信息保存完毕!!\n");
            getcH();
        }
        else if (select_paper == 'c')
        {
            printf("\n请输入要导入的文件名:");
            scanf("%s", Path);
            cleanbuff();
RETU_QUEE:
            tmp_paper_counter=0;
            for(int rr=0;rr<tu;rr++)
            {
                if(strcmp(tmp_paper[rr],Path)==0)
                    tmp_paper_counter++;//对这个导入的文件名计数
            }
            if(tmp_paper_counter !=0)//该文件被导入了
            {
                printf("\n您已经导入过文件——%s——了,将制止您这次行为......\n",Path);
                getcH();
            }
            else//该文件未被导入过
            {
                if ((filp = fopen(Path, "r")) == NULL)
                {
                    char quee;
                    printf("\n文件打开失败!!!请选择继续(a)还是退出(b)......");
                    quee = getche();
                    while (quee != 'a' || quee != 'b')
                    {
                        printf("无该选项!\n");
                        quee = getche();
                    }
                    if (quee == 'a')
                    {
                        printf("\n重新输入文件名:");
                        scanf("%s", Path);
                        cleanbuff();
                        goto RETU_QUEE;
                    }
                    else goto RETU_FILP;
                }
                unsigned int id_temp;
                char name_temp[20];
                float e, c, m;
                while (fscanf(filp, "%s %u %f %f %f\n", name_temp, &id_temp, &c, &m, &e) != EOF)
                {
                    node* pnew;
                    if (count_global == 0)   //不是第一次建立,则跳过
                    {
                        L = (node*)malloc(sizeof(node));
                        L->next = NULL;
                        L->sie = NULL;
                        L->rage = NULL;
                        end = L;
                        eNd = L;
                        enD = L;
                    }
                    pnew = (node*)malloc(sizeof(node));
                    strcpy(pnew->stu.name, name_temp);
                    pnew->stu.id = id_temp;
                    pnew->stu.mare = m;
                    pnew->stu.chre = c;
                    pnew->stu.enre = e;
                    if (count_global == 0)//尾插法
                    {
                        pnew->next = end->next;
                        pnew->sie = eNd->sie;
                        pnew->rage = enD->rage;//
                        end->next = pnew;
                        eNd->sie = pnew;
                        enD->rage = pnew;
                        end = pnew;  //三个指针的含义不同,所以要分别赋值
                        eNd = pnew;
                        enD = pnew;
                    }
                    else
                    {  //姓名排序算法
                        if (strcmp(pnew->stu.name, (L->next)->stu.name) < 0)//头插法
                        {
                            pnew->next = L->next;
                            L->next = pnew;
                        }
                        else if (strcmp(pnew->stu.name, end->stu.name) >= 0)//尾插法
                        {
                            pnew->next = end->next;
                            end->next = pnew;
                            end = pnew;
                        }
                        else
                        {
                            node* after = L->next, * before = after->next;  //搜索指针。按姓名排列。
                            while (1)
                            {
                                if (strcmp(after->stu.name, pnew->stu.name) <= 0 && strcmp(pnew->stu.name, before->stu.name) <= 0)  //中间插法
                                {
                                    after->next = pnew;
                                    pnew->next = before;
                                    break;
                                }
                                after = after->next;
                                before = before->next;
                                if (before == NULL)//尾插法
                                {
                                    pnew->next = end->next;
                                    end->next = pnew;
                                    end = pnew;
                                    break;
                                }
                            }
                        }   //姓名排序完成,开始学号排序。
                        if (pnew->stu.id < (L->sie)->stu.id)//头插法
                        {
                            pnew->sie = L->sie;
                            L->sie = pnew;
                        }
                        else if (pnew->stu.id >= eNd->stu.id)//尾插法
                        {
                            pnew->sie = eNd->sie;
                            eNd->sie = pnew;
                            eNd = pnew;
                        }
                        else
                        {
                            node* after = L->sie, * before = after->sie;//搜索指针。按学号排列。
                            while (1)
                            {
                                if (pnew->stu.id >= after->stu.id && pnew->stu.id <= before->stu.id)  //中间插法
                                {
                                    after->sie = pnew;
                                    pnew->sie = before;
                                    break;
                                }
                                after = after->sie;
                                before = before->sie;
                                if (before == NULL)//尾插法
                                {
                                    pnew->sie = eNd->sie;
                                    eNd->sie = pnew;
                                    eNd = pnew;
                                    break;
                                }
                            }
                        }//学号排序完成,开始分数排序。
                        if ((pnew->stu.enre) + (pnew->stu.chre) + (pnew->stu.mare) < ((L->rage)->stu.enre) + ((L->rage)->stu.mare) + ((L->rage)->stu.chre))//头插法
                        {
                            pnew->rage = L->rage;
                            L->rage = pnew;
                        }
                        else if ((pnew->stu.enre) + (pnew->stu.chre) + (pnew->stu.mare) >= (enD->stu.enre) + (enD->stu.mare) + (enD->stu.chre))//尾插法
                        {
                            pnew->rage = enD->rage;
                            enD->rage = pnew;
                            enD = pnew;
                        }
                        else
                        {
                            node* after = L->rage, * before = after->rage;   //搜索指针。按分数排列。
                            while (1)
                            {
                                if (((pnew->stu.enre) + (pnew->stu.chre) + (pnew->stu.mare) >= (after->stu.enre) + (after->stu.mare) + (after->stu.chre)) && ((pnew->stu.enre) + (pnew->stu.chre) + (pnew->stu.mare) <= (before->stu.enre) + (before->stu.mare) + (before->stu.chre))) //中间插法
                                {
                                    after->rage = pnew;
                                    pnew->rage = before;
                                    break;
                                }
                                after = after->rage;
                                before = before->rage;
                                if (before == NULL)//尾插法
                                {
                                    pnew->rage = enD->rage;
                                    enD->rage = pnew;
                                    enD = pnew;
                                    break;
                                }
                            }
                        }
                    }
                    count_global++;
                }
                fclose(filp);
                strcpy(tmp_paper[tu++],Path);//为防止读入同一个文件做铺垫
                printf("添加完成,我将返回(任意击建继续.......)");
                getcH();
            }
        }
        else if(select_paper=='d')//查看导入的文件名
        {
            if(tu==0)
                printf("\n您还没有导入过文件!!!\n");
            else
            {
                printf("\n已经导入的文件有%d个:\n",tu);
                for(int j=0;j<tu;j++)
                    printf("\t\t\t%-s\n",tmp_paper[j]);
            }
            getcH();
        }
        else break;
    }
}

int delete_node()//删除模块   无bug
{
    if (count_global==0)
	{
		printf("您还未录入成员!!!\n");
		getcH();
		return 0;
	}
    node*delete_list=accurate_search(),* before,* seek;//delete_list通过自建函数accurate_search()找到要删除的对象,before是对象前面节点、seek是搜索指针。
    if(delete_list==NULL)
    {
        printf("没有找到你要删除的对象.....");
        getcH();
    }
    else
    {
        printf("   你要删除的对象为:\n姓名:%-*s\n学号:%-11u\n语文:%-5.2f\n数学:%-5.2f\n英语:%-5.2f\n", 19,delete_list->stu.name,delete_list->stu.id,delete_list->stu.chre, delete_list->stu.mare, delete_list->stu.enre);
        printf("是否删除?(按-删除)");/*上面的打印为什么不调用显示函数display(),是因为我在显示函数里加了gecH(),这里不需要等待*/
        char ENter; ENter=getche();//注意修改
        cleanbuff();
        if ( ENter!='-' )  return 0;   //判断是否继续修改
        seek=L;
        before=L;
        while((seek=seek->next)!=NULL)//修改next域
        {
            if(seek!=delete_list)  before=before->next;
            else before->next=seek->next;
        }
        seek=L;
        before=L;
        while((seek=seek->sie)!=NULL)//修改sie域
        {
            if(seek!=delete_list)  before=before->sie;
            else before->sie=seek->sie;
        }
        seek=L;
        before=L;
        while((seek=seek->rage)!=NULL)//修改rage域
        {
            if(seek!=delete_list)  before=before->rage;
            else before->rage=seek->rage;
        }
        free(delete_list);
        count_global--;//将总人数减一
        printf("\n已经将其删除了.....我将返回.......\n");
        getcH();
    }
    return 0;
}


  • 1
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值