⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 main.cpp

📁 关于教学管理的数据库
💻 CPP
字号:
#include<iostream.h>
#include<stdlib.h>
#include<conio.h>
#include"head.h"

extern void Create(Student* &);
extern void Change(Student* &);
extern void ClassAverage(Student* &);
extern void ChangeScore(Student* &);
extern void DeleteStudent(Student* &);
extern void DeleteClass(Student* &);
extern void DeleteAll(Student* &);
extern void DisplayBasic(Student* &);
extern void DisplayOneBasic(Student* &);
extern void DisplayScore(Student* &);
extern void DisplayOneScore(Student* &);
extern void DisplayAllRank(Student* &);
extern void DisplayClassRank(Student* &);
extern void DisplayCopyright();
extern void FindFail(Student* &);
extern void Getout(Student* &);
extern void Insert(Student* &);
extern void SortAll(Student* &);
extern void SortByClass(Student* &);
extern void SortEachClass(Student* &);
extern void Save(Student* &);
extern void WriteScore(Student* &);

void main()
{
	Student* List;
	Student* &head=List;
	head=NULL;
	char choice1,choice2;

	Getout(head);

status1:
	if(head==NULL)
	{
		cout<<"这是您第一次使用本程序,由于文件中还没有任何学生信息,下面程序将引导您提示创建学生信息文件."<<endl;
		system("pause");
		Create(head);
	}
	
	system("cls");
	cout<<endl<<endl<<endl;
	cout<<"主菜单:"<<endl;
	cout<<"			1.管理学生的基本信息..."<<endl<<endl
		<<"			2.管理学生的成绩..."<<endl<<endl
		<<"			3.保存学生的基本信息和成绩"<<endl<<endl
		<<"			4.关于本程序"<<endl<<endl
		<<"			0.退出"<<endl<<endl<<endl<<endl<<endl
		<<"                     请选择:  (只需键入数字,不必按回车.)"<<endl;
	choice1=getche();

	if(choice1=='1')
	{
status2:
		system("cls");
		cout<<endl<<endl<<endl;
		cout<<"			1.插入学生的基本信息"<<endl<<endl
			<<"			2.显示某个学生的基本信息"<<endl<<endl
			<<"			3.修改某个学生的基本信息"<<endl<<endl
			<<"			4.显示所有学生的基本信息"<<endl<<endl
			<<"			5.删除某个学生的基本信息"<<endl<<endl
			<<"			6.删除某个班级所有学生的基本信息"<<endl<<endl
			<<"			0.返回主菜单"<<endl<<endl<<endl<<endl
			<<"			请选择:  (只需键入数字,不必按回车)"<<endl;
		choice2=getch();

		if(choice2=='1')
		{
			system("cls");
			Insert(head);
		}
		else if(choice2=='2')
		{
			system("cls");
			DisplayOneBasic(head);
		}
		else if(choice2=='3')
		{
			system("cls");
			Change(head);
		}
		else if(choice2=='4')
		{
			system("cls");
			DisplayBasic(head);
		}
		else if(choice2=='5')
		{
			system("cls");
			DeleteStudent(head);
		}
		else if(choice2=='6')
		{
			system("cls");
			DeleteClass(head);
		}
		else if(choice2=='0')
		{
			system("cls");
			goto status1;
		}
		else
		{
			cout<<"您的选择有错,请重新输入:";
			choice2=getch();
			goto status2;
		}
		system("pause");
		system("cls");
		goto status2;
	}

	else if(choice1=='2')
	{
status3:
		system("cls");
		cout<<endl<<endl<<endl;
		cout<<"			1.登记或修改多个学生的成绩"<<endl<<endl
			<<"			2.显示某个学生的成绩"<<endl<<endl
			<<"			3.修改某个学生的成绩"<<endl<<endl
			<<"			4.显示年级排名"<<endl<<endl
			<<"			5.显示各班级排名"<<endl<<endl
			<<"			6.显示各班各科目的平均成绩和总平均成绩"<<endl<<endl
			<<"			7.显示不及格的学生及其不及格的科目"<<endl<<endl
			<<"			0.返回主菜单"<<endl<<endl<<endl<<endl
			<<"			请选择: (只需键入数字,不必按回车)"<<endl;
		choice2=getch();

		if(choice2=='1')
		{
			system("cls");
			WriteScore(head);
		}
		else if(choice2=='2')
		{
			system("cls");
			DisplayOneScore(head);
		}
		else if(choice2=='3')
		{
			system("cls");
			ChangeScore(head);
		}
		else if(choice2=='4')
		{
			system("cls");
			SortAll(head);
			DisplayAllRank(head);
		}
		else if(choice2=='5')
		{
			system("cls");
			SortEachClass(head);
			DisplayClassRank(head);
		}
		else if(choice2=='6')
		{
			system("cls");
			ClassAverage(head);
		}
		else if(choice2=='7')
		{
			system("cls");
			FindFail(head);
		}
		else if(choice2=='0')
		{
			system("cls");
			goto status1;
		}
		else
		{
			cout<<"您的选择有错,请重新输入:";
			goto status3;
		}
		system("pause");
		system("cls");
		goto status3;
	}
	
	else if(choice1=='3')
	{
		system("cls");
		Save(head);
		system("pause");
		system("cls");
		goto status1;
	}
	else if(choice1=='4')
	{
		system("cls");
		DisplayCopyright();
		system("pause");
		goto status1;
	}
	else if(choice1=='0')
	{
		system("cls");
status4:
		cout<<"退出程序前保存对学生信息的修改吗?(y/n): "<<endl;
		choice2=getch();

		if(choice2=='y'||choice2=='Y')
		{
			Save(head);
		}
		else if(choice2!='y'&&choice2!='Y'&&choice2!='n'&&choice2!='N')
		{
			cout<<"输入的内容有错,请重新输入."<<endl;
			goto status4;
		}
		DeleteAll(head);       //退出程序前应当释放内存!
	}
	else
	{
		cout<<"输入的内容有错,请重新选择."<<endl;
		system("pause");
		system("cls");
		goto status1;
	}
	system("pause");
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -