#define _CRT_SECURE_NO_WARNINGS
#include
#include
#include<stdlib.h>
using namespace std;
struct Students {
string name[1000];
string id[1000];
string sex[1000];
int age[1000];
float score[1000];
}s = {
{" “},
{” “},
{” “},
{0},
{0}
};
string delete_ID[100] = {” " };
int meau()
{
cout << “#######################################” << endl;
cout << “欢迎来到德莱联盟,请输入您的选择” << endl;
cout << “1.进入系统” << endl;
cout << “2.退出系统”<<endl;
cout << “#######################################” << endl;
int choice = 0;
cin >> choice;
return choice;
}
void Setup_information(int max)
{
for (int i = 0;i < max;i++)
{
cout << "姓名: ";
cin >> s.name[i];
cout << "学号: ";
cin >> s.id[i];
cout << "性别: ";
cin >> s.sex[i];
cout << "年龄: ";
cin >> s.age[i];
cout << "分数: ";
cin >> s.score[i];
if (i < max-1)
{
cout << “下一个” << endl << endl;
}
}
}
int meau2()
{
cout << “#####################################################” << endl;
cout << “0.创建学生的信息” << endl;
cout << “1.查看所有学生的的信息以及成绩排名情况” << endl;
cout << “2.查看某个学生的信息” << endl;
cout << “3.修改某个学生的信息” << endl;
cout << “4.删除某个学生的信息” << endl;
cout << “5.添加学生信息” << endl;
cout << “6.返回上一级” << endl;
cout << “7.返回到主菜单” << endl;
cout << “#####################################################” << endl;
int choice = 0;
cin >> choice;
return choice;
}
void arrange(int max)
{
for (int i = max - 1;i > 0;i–)
{
for (int j=0;j<i;j++)
{
if (s.score[j] < s.score[j+1])
{
swap(s.name[j], s.name[j + 1]);
swap(s.id[j], s.id[j + 1]);
swap(s.sex[j], s.sex[j + 1]);
swap(s.age[j], s.age[j + 1]);
swap(s.score[j], s.score[j + 1]);
}
}
}
}
void Look_all(int max)
{
for (int i = 0; i < max; i++)
{
if (s.id[i] != delete_ID[i])
{
cout << "姓名: " << s.name[i] << endl;
cout << "学号: " << s.id[i] << endl;
cout << "性别: " << s.sex[i] << endl;
cout << "年龄: " << s.age[i] << endl;
cout << "成绩: " << s.score[i] << endl << endl << endl;
}
else {
cout << “所找信息不存在”<<endl;
continue;
}
}
}
int Find(string ID,int max)
{
for (int i = 0;i < max;i++)
{
if (s.id[i] == ID)
{
return i;
}
}
return -1;
}
void Look_one(int max)
{
char choice=0;
while (1)
{
string ID;
cout << "请输入学生的学号: ";
cin >> ID;
int i = Find(ID, max);
if (i == -1||s.id[i]==delete_ID[i])
{
cout << “您的输入有误”<<endl;
cout << “请确认是否继续” << endl << “y.继续” << endl;
cin >> choice;
if (choice == ‘y’)
continue;
else {
break;
}
}
else {
cout << "姓名: " << s.name[i] << endl;
cout << "学号: " << s.id[i] << endl;
cout << "性别: " << s.sex[i] << endl;
cout << "年龄: " << s.age[i] << endl;
cout << "成绩: " << s.score[i] << endl << endl << endl;
cout << “请确认是否继续” << endl << “y.继续” << endl;
cin >> choice;
if (choice == ‘y’)
continue;
else {
break;
}
}
}
}
void Modfy(int max)
{
char choice=0;
while (1)
{
string ID;
cout << "请输入学生的学号: ";
cin >> ID;
int i = Find(ID, max);
if (i == -1||delete_ID[i]==s.id[i])
{
cout << “您的输入有误”<<endl;
cout << “请确认是否继续” << endl << “y.继续” << endl;
cin >> choice;
if (choice == ‘y’)
continue;
else {
break;
}
continue;
}
else
{
cout << "姓名: ";
cin >> s.name[i];
cout << "学号: ";
cin >> s.id[i];
cout << "性别: ";
cin >> s.sex[i];
cout << "年龄: ";
cin >> s.age[i];
cout << "分数: ";
cin >> s.score[i];
cout << “修改成功!!” << endl;
cout << “请确认是否继续” << endl << “y.继续”<<endl;
cin >> choice;
if (choice == ‘y’)
continue;
else {
break;
}
}
}
}
void Delete(int max)
{
char choice = 0;
while (1)
{
string ID;
cout << "请输入学生的学号: ";
cin >> ID;
int i = Find(ID, max);
if (i == -1||s.id[i]delete_ID[i] )
{
cout << “您的输入有误” << endl;
cout << “请确认是否继续” << endl << “y.继续” << endl;
cin >> choice;
if (choice == ‘y’)
continue;
else {
break;
}
}
else {
delete_ID[i] = s.id[i];
cout << “删除成功!!!” << endl;
cout << “请确认是否退出” << endl << “y.继续” << endl;
cin >> choice;
if (choice == ‘y’)
continue;
else {
break;
}
}
}
}
void Add_information(int &max)
{
char choice = ’ ';
while (1)
{
max++;
cout << "姓名: ";
cin >> s.name[max-1];
cout << "学号: ";
cin >> s.id[max-1];
cout << "性别: ";
cin >> s.sex[max-1];
cout << "年龄: ";
cin >> s.age[max-1];
cout << "分数: ";
cin >> s.score[max-1];
cout << “创建完成” << endl;
cout << “是否继续???” << endl << “继续请输入y”<<endl;
cin >> choice;
if (choice == ‘y’)
{
continue;
}
else {
break;
}
}
}
int Teaching_information_manage_system()
{
int max = 0;
while (1)
{
int flag = meau2();
if (flag == 0)
{
cout << "请输入学生的人数: ";
cin >> max;
Setup_information(max);
arrange(max);
}
else if (flag == 1)
{
Look_all(max);
}
else if (flag2)
{
Look_one(max);
}
else if (flag == 3)
{
Modfy(max);
}
else if (flag == 4)
{
Delete(max);
}
else if (flag == 5)
{
Add_information(max);
}
else if (flag == 6)
{
Teaching_information_manage_system();
}
else if (flag == 7)
{
return meau();
}
else {
cout << “您的输入有误”;
}
}
}
int main()
{
int flag2 = 0;
while (1)
{
if (flag2 == 1)
{
Teaching_information_manage_system();
}
else if (flag2 == 2)
{
break;
}
else {
int flag = meau();
if (flag == 1)
{
flag2 = Teaching_information_manage_system();
continue;
}
else if (flag == 2)
{
break;
}
else {
cout << "您的输入有误" << endl;
continue;
}
}
}
}