?? main.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 + -