##学生信息管理系统
问题1:登录时的动画效果
分析:运用心形函数和for循环再用*来填充
问题2:主菜单的子选项
分析:运用if else循环嵌套,进行选择
问题3:输入学生信息
分析:调用函数模块,运用do while 循环,再运用cin进行逐一输入
问题4:显示学生信息
分析:运用for循环逐一显示
问题5:查询、显示、删除学生信息
分析:先输入学号再和之前输入的学生信息逐一检索,看是否匹配,再运用if else循环修改
问题6:将学生信息排序
分析:调用sort函数直接进行排序
问题7:统计学生信息
分析:定义几个数值为0的变量当有那门课的成绩低于60的时候相应的变量就加一,最后输出;
三、核心代码实现
关键代码
(一)、在该系统中,我们使用了最为关键的vectory向量,struct结构体、对象类型和while(1)循环语句以及文件输入输出流类ifstream和ofstream。
1.struct结构体中,我们在主函数之前定义了如下成员:
struct student
{
string no;
string name;
string age;
string sex;
double math;
double C;
double English;
double sum;
float aver;
};
分别用于存放学生的学号、姓名、年龄、性别、三科成绩、总分和平均分。定义后我们声明了vectory这个容器来存放结构体,用于之后在类里成员函数输入和读取学生信息。其中成员string no,string name是用来存放姓名和学号,相同类型有助于同时查询学号或姓名。score[]数组里前三个成员用于存放分数,score[3]=(score[0]+score[1]+score[2])/3求出平均分并存放于三科分数之后。通过通过向量对结构体的调用实现对分数等的输入和输出。}
2.因为向量是数组的优化也是可伸缩的数组,所以简化了对输入的操作,我们在主函数外定义了以下函数模块,调用相应的函数实现相应的功能:
1.void add(vector &a,student &t); //输入学生信息
2.void print(vector &a); //打印显示学生信息
3.void modify(vector &a,string t); //修改学生信息
4.void deletew(vector &a,string t); //删除学生信息
5.void search(vector &a,string t); //查询学生信息
6.void sorting(vector &a,string m,string n); //给学生信息排序
7.void count(vector &a); //统计学生信息
8.为实现模块之间的循环调用,我们使用了while(1)循环语句,并在while里通过if(option!=1)而运行至break退出模块循环,从而达到了对各个模块之间的调用。
While(true)
{
Int v=0;
While(true)
{
}
If(v1)
{
break;
}
}
1.各个模块之间的划分我们通过使用if else 语句,将每个需要调用的成员函数放在if的主体中里,达到在菜单里选择各个模块而实现各个函数成员的调用的目的。
if(option”1”)
{
if(option==”1”)
{
…
}
}
else
If(option==”2”)
{
…
}
else
…
5.为实现数据存入文件和从文件读入数据的目的,我们充分应用了课堂上学习的文件流类相关知识,利用ifstream定义了< >输入符、ofstream定义了< >读取符,实现了有关文件的相关操作。
ofstream zjw(“zjw.txt”,ios::out);
input<<" 学生成绩表"<<endl;
cout << ino << " " << iname << " " << isex << " “<<iage<<” "
<< math << " " << English << " " << c << " " << sum << " " << aver << endl;
cout << “--------------------------------------------------------------------------” << endl;
ifstream read(“学生成绩表.txt”);
zjw << ino << " " << iname << " " << isex << " “<<iage<<” "
<< math << " " << English << " " << c << " " << sum << " " << aver << endl;
zjw << “--------------------------------------------------------------------------” << endl;
for (vector ::size_type i = 0; i < a.size(); i++) {
if (a.at(i).no != “0”) {
zjw << “|” << a.at(i).no << setw(12 - a.at(i).no.size()) << “|” << a.at(i).name << setw(12 - a.at(i).name.size())
<< “|” << a.at(i).sex << setw(10 - a.at(i).sex.size()) <<"|"<<a.at(i).age<<setw(10-a.at(i).age.size())<< “|” << a.at(i).math << setw(8 - get_width(a.at(i).math))
<< “|” << a.at(i).English << setw(8 - get_width(a.at(i).English)) << “|” << a.at(i).C
<< setw(8 - get_width(a.at(i).C)) << “|” << a.at(i).sum << setw(8 - get_width(a.at(i).sum))
<< “|” << a.at(i).aver << endl;
zjw << “--------------------------------------------------------------------------” << endl; (二)、除了几个关键的语句外,我们还使用了一些较为灵活的系统函数。
1.我们使用sort函数进行排序简单快捷
我们调用algorithm头文件中的函数实现排序
sort(a.begin(),a.end(),downorder_C);
include
include
include
include
include
include<windows.h>
include
include
using namespace std;
define T 100
int N=0;
struct student
{
string no;
string name;
string age;
string sex;
double math;
double C;
double English;
double sum;
float aver;
};
void add(vector &a,student &t);
void print(vector &a);
void modify(vector &a,string t);
void deletew(vector &a,string t);
void search(vector &a,string t);
void sorting(vector &a,string m,string n);
void count(vector &a);
bool uporder_math(const student &stu1,const student &stu2);
bool uporder_C(const student &stu1,const student &stu2);
bool uporder_English(const student &stu1,const student &stu2);
bool uporder_sum(const student &stu1,const student &stu2);
bool downorder_math(const student &stu1,const student &stu2);
bool downorder_C(const student &stu1,const student &stu2);
bool downorder_English(const student &stu1,const student &stu2);
bool downorder_sum(const student &stu1,const student &stu2);
int main()
{
vector a;
student t;
int i,j;
double x,y;
string option1,option2,option3,option4;
string decision,nu,subject,order;
string name1,name2,name3,password1,password2,password3;
name1=“何跃”;
password1=“341125”;
while(true)
{
system(“color B4”);
cout<<“学生信息管理系统”<<endl;
cout<<“1、登录进入学生信息管理系统”<<endl;
cout<<“2、重置使用者信息和密码”<<endl;
cout<<“3、退出该系统”<<endl;
cout<<“请输入你要执行的选项:”;
cin>>option1;
if(option1==“1”)
{
cout<<“请输入用户名:”;
cin>>name2;
cout<<“请输入密码:”;
cin>>password2;
system(“cls”);
cout << " 敲个代码都是爱你的形状" << endl;
for (y = 1.4f; y > -1.2f; y -= 0.1f)
{
for (x = -1.5f; x < 1.5f; x += 0.05f) {
double k = x * x + y * y - 1;
if ((k * k * k - x * x * y * y * y) <= 0) {
cout << “";
}
else {
cout << " “;
}
}
cout << endl;
Sleep(100);
}
if(name2name1&&password2password1)
{
cout<<“登录成功!”<<endl;
system(“pause”);
system(“cls”);
while(true)
{
cout<<”********* 菜单 **********”<<endl;
cout<<“1、输入学生信息”<<endl;
cout<<“2、显示学生信息”<<endl;
cout<<“3、修改学生信息”<<endl;
cout<<“4、删除学生信息”<<endl;
cout<<“5、查询学生信息”<<endl;
cout<<“6、将学生成绩排序”<<endl;
cout<<“7、统计学生信息”<<endl;
cout<<“8、返回上一界面”<<endl;
cout<<“9、退出系统”<<endl;
cout<<“请输入要执行选项:”;
cin>>option2;
if(option2==“1”)
{
system(“cls”);
cout<<“输入学生信息”<<endl;
cout<<“注意:输入0 0 0 0 0 0结束该功能”<<endl;
cout<<" 学号 姓名 性别 年龄 高数 C 英语"<<endl;
add(a,t);
cout<<“1、回到菜单”<<endl;
cout<<“2、退出系统”<<endl;
cout<<“请输入要执行的选项:”;
while(true)
{
cin>>option3;
if(option3==“1”)
{
system(“cls”);
break;
}
else
if(option3==“2”)
{
return 0;
}
else
{
cout<<“1、回到菜单”<<endl;
cout<<“2、退出系统”<<endl;
cout<<“所输入结果不符合要求!”<<endl;
cout<<“请重新输入”<<endl;
}
}
}
else
if(option2==“2”)
{
system(“cls”);
cout<<“显示学生信息”<<endl;
print(a);
cout<<“1、回到菜单”<<endl;
cout<<“2、退出系统”<<endl;
cout<<“请输入要执行的选项:”;
while(true)
{
cin>>option3;
if(option3==“1”)
{
system(“cls”);
break;
}
else
if(option3==“2”)
{
return 0;
}
else
{
cout<<“1、回到菜单”<<endl;
cout<<“2、退出系统”<<endl;
cout<<“所输入结果不符合要求!”<<endl;
cout<<“请重新输入”<<endl;
}
}
}
else
if(option2==“3”)
{
int v=0;
system(“cls”);
cout<<“修改学生信息”<<endl;
while(true)
{
cout<<“请输入学号:”;
cin>>nu;
modify(a,nu);
cout<<“1、回到菜单”<<endl;
cout<<“2、退出系统”<<endl;
cout<<“3、再次修改”<<endl;
cout<<“请输入要执行的选项:”;
while(true)
{
cin>>option3;
if(option3==“1”)
{
v=1;
system(“cls”);
break;
}
else
if(option3==“2”)
{
return 0;
}
else
if(option3==“3”)
{
break;
}
else
{
cout<<“1、回到菜单”<<endl;
cout<<“2、退出系统”<<endl;
cout<<“所输入结果不符合要求!”<<endl;
cout<<“请重新输入”<<endl;
}
}
if(v1)
{
break;
}
}
}
else
if(option2"4")
{
system(“cls”);
cout<<“删除学生信息”<<endl;
while(true)
{
int v=0;
cout<<“输入要删除同学的学号:”;
cin>>nu;
deletew(a,nu);
cout<<“1、回到菜单”<<endl;
cout<<“2、退出系统”<<endl;
cout<<“3、继续删除”<<endl;
cout<<“请输入要执行的选项:”;
while(true)
{
cin>>option3;
if(option3==“1”)
{
v=1;
system(“cls”);
break;
}
else
if(option3==“2”)
{
return 0;
}
else
if(option3==“3”)
{
break;
}
else
{
cout<<“1、回到菜单”<<endl;
cout<<“2、退出系统”<<endl;
cout<<“3、继续删除”<<endl;
cout<<“所输入结果不符合要求!”<<endl;
cout<<“请重新输入”<<endl;
}
}
if(v1)
{
break;
}
}
}
else
if(option2"5")
{
int v=0;
system(“cls”);
cout<<“查询学生信息”<<endl;
while(true)
{
cout<<“输入要查询同学的学号:”;
cin>>nu;
search(a,nu);
cout<<“1、回到菜单”<<endl;
cout<<“2、退出系统”<<endl;
cout<<“3、再次查询”<<endl;
cout<<“请输入要执行的选项:”;
while(true)
{
cin>>option3;
if(option3==“1”)
{
v=1;
system(“cls”);
break;
}
else
if(option3==“2”)
{
return 0;
}
else
if(option3==“3”)
{
break;
}
else
{
cout<<“1、回到菜单”<<endl;
cout<<“2、退出系统”<<endl;
cout<<“3、再次查询”<<endl;
cout<<“所输入结果不符合要求!”<<endl;
cout<<“请重新输入”<<endl;
}
}
if(v1)
{
break;
}
}
}
else
if(option2"6")
{
int v=0;
system(“cls”);
cout<<“将学生成绩进行排序”<<endl;
while(true)
{
cout<<“1、高数”<<endl;
cout<<“2、计算机”<<endl;
cout<<“3、英语”<<endl;
cout<<“4、总分”<<endl;
cout<<“请选择要排序的科目:”<<endl;
cin>>subject;
cout<<“1、从高到低”<<endl;
cout<<“2、从低到高”<<endl;
cout<<“请选择排序方式:”<<endl;
cin>>order;
sorting(a,subject,order);
cout<<“1、回到菜单”<<endl;
cout<<“2、退出系统”<<endl;
cout<<“3、再次排序”<<endl;
cout<<“请输入要执行的选项:”;
while(true)
{
cin>>option3;
if(option3==“1”)
{
v=1;
system(“cls”);
break;
}
else
if(option3==“2”)
{
return 0;
}
if(option3==“3”)
{
break;
}
else
{
cout<<“1、回到菜单”<<endl;
cout<<“2、退出系统”<<endl;
cout<<“3、再次排序”<<endl;
cout<<“所输入结果不符合要求!”<<endl;
cout<<“请重新输入”<<endl;
}
}
if(v1)
{
break;
}
}
}
else
if(option2"7")
{
system(“cls”);
cout<<“统计学生信息”<<endl;
count(a);
cout<<“1、回到菜单”<<endl;
cout<<“2、退出系统”<<endl;
cout<<“请输入要执行的选项:”;
while(true)
{
cin>>option3;
if(option3==“1”)
{
system(“cls”);
break;
}
else
if(option3==“2”)
{
return 0;
}
else
{
cout<<“1、回到菜单”<<endl;
cout<<“2、退出系统”<<endl;
cout<<“所输入结果不符合要求!”<<endl;
cout<<“请重新输入”<<endl;
}
}
}
else
if(option2==“9”)
{
system(“cls”);
break;
}
else
if(option2==“10”)
{
return 0;
}
}
}
else
{
cout<<“输入错误!请重新输入”<<endl;
system(“pause”);
system(“cls”);
}
}
else
if(option1==“2”)
{
system(“cls”);
cout<<“请输入原用户名:”;
cin>>name3;
cout<<“请输入原密码:”;
cin>>password3;
system(“cls”);
if(name3name1&&password3password1)
{
system(“cls”);
while(true)
{
cout<<“菜单”<<endl;
cout<<“1、修改用户名”<<endl;
cout<<“2、修改密码”<<endl;
cout<<“3、返回主页面”<<endl;
cout<<“请输入要执行的操作:”;
cin>>option4;
if(option4==“1”)
{
cout<<“请输入新的用户名:”;
cin>>name1;
system(“cls”);
}
else
if(option4==“2”)
{
cout<<“请输入新的密码:”;
cin>>password1;
system(“cls”);
}
else
if(option4==“3”)
{
system(“cls”);
break;
}
else
{
cout<<“输入错误!请重新输入”;
}
}
}
else
{
cout<<“输入错误!请重新输入”<<endl;
system(“pause”);
system(“cls”);
}
}
else
if(option1==“3”)
{
return 0;
}
else
{
cout<<“输入格式错误!请重新输入”<<endl;
system(“pause”);
system(“cls”);
}
}
return 0;
}
int get_width(double n)
{
stringstream ss;
string temp;
ss << n;
ss >> temp;
return temp.size();
}
void add(vector &a,student &t)
{
do{
cin>>t.no>>t.name>>t.sex>>t.age>>t.math>>t.C>>t.English;
t.sum=t.math+t.C+t.English;
t.aver=t.sum/3;
a.push_back(t);
if(t.sex!=“男”&&t.sex!=“女”&&t.sex!=“0”)
{
cout<<“性别输入错误(性别只有男或女)!”<<endl;
deletew(a,t.no);
cout<<“请重新输入:”<<endl;
continue;
}
if(t.age<“0”)
{
cout<<“年龄输入错误(年龄不能为负数)”<<endl;
deletew(a,t.no);
cout<<“请重新输入:”<<endl;
continue;
}
if(t.math>100||t.math<0)
{
cout<<“高数输入错误(成绩范围为0~100)”<<endl;
deletew(a,t.no);
cout<<“请重新输入:”<<endl;
continue;
}
if(t.C>100||t.C<0)
{
cout<<“计算机成绩输入错误(成绩范围为0~100)”<<endl;
deletew(a,t.no);
cout<<“请重新输入:”<<endl;
continue;
}
if(t.English>100||t.English<0)
{
cout<<“英语成绩输入错误(成绩范围为0~100)”<<endl;
deletew(a,t.no);
cout<<“请重新输入:”<<endl;
continue;
}
}while(t.no!= “0”);
}
void print(vector &a)
{
string ino, iname, isex,iage, math, English, c, sum, aver;
ino = “|学号”; iname = “|姓名”; isex = “|性别”;iage="|年龄"; math = “|数学”;
English = “|英语”; c = “|计算机”; sum = “|总分”; aver = “|平均分”;
ofstream zjw(“text.txt”);
string choice;
cout << ino << " " << iname << " " << isex << " “<<iage<<” "
<< math << " " << English << " " << c << " " << sum << " " << aver << endl;
cout << “--------------------------------------------------------------------------” << endl;
for (vector ::size_type i = 0; i < a.size(); i++)
{
if (a.at(i).no != “0”)
{
cout << “|” << a.at(i).no << setw(12 - a.at(i).no.size()) << “|” << a.at(i).name << setw(12 - a.at(i).name.size())
<< “|” << a.at(i).sex << setw(10 - a.at(i).sex.size()) <<"|"<<a.at(i).age<<setw(10-a.at(i).age.size())<< “|” << a.at(i).math << setw(8 - get_width(a.at(i).math))
<< “|” << a.at(i).English << setw(8 - get_width(a.at(i).English)) << “|” << a.at(i).C
<< setw(8 - get_width(a.at(i).C)) << “|” << a.at(i).sum << setw(8 - get_width(a.at(i).sum))
<< “|” << a.at(i).aver << endl;
cout << “--------------------------------------------------------------------------” << endl;
}
}
cout << “你是否将数据保存到文件(Y/N):”;
while (true)
{
cin >> choice;
if (“Y” == choice) {
zjw << ino << " " << iname << " " << isex << " “<<iage<<” "
<< math << " " << English << " " << c << " " << sum << " " << aver << endl;
zjw << “--------------------------------------------------------------------------” << endl;
for (vector ::size_type i = 0; i < a.size(); i++) {
if (a.at(i).no != “0”) {
zjw << “|” << a.at(i).no << setw(12 - a.at(i).no.size()) << “|” << a.at(i).name << setw(12 - a.at(i).name.size())
<< “|” << a.at(i).sex << setw(10 - a.at(i).sex.size()) <<"|"<<a.at(i).age<<setw(10-a.at(i).age.size())<< “|” << a.at(i).math << setw(8 - get_width(a.at(i).math))
<< “|” << a.at(i).English << setw(8 - get_width(a.at(i).English)) << “|” << a.at(i).C
<< setw(8 - get_width(a.at(i).C)) << “|” << a.at(i).sum << setw(8 - get_width(a.at(i).sum))
<< “|” << a.at(i).aver << endl;
zjw << “--------------------------------------------------------------------------” << endl;
}
}
cout << “保存成功!” << endl;
break;
}
else if (“N” == choice) {
break;
}
else {
cout << “输入错误,请重新输入:”;
}
}
}
void modify(vector &a,string no)
{
int flag=0;
string num;string ino, iname, isex,iage, math, English, c, sum, aver;
ino = “|学号”; iname = “|姓名”; isex = “|性别”;iage="|年龄"; math = “|数学”;
English = “|英语”; c = “|计算机”; sum = “|总分”; aver = “|平均分”;
cout << ino << " " << iname << " " << isex << " “<<iage<<” "
<< math << " " << English << " " << c << " " << sum << " " << aver << endl;
cout << “--------------------------------------------------------------------------” << endl;
for(vector ::size_type i=0;i<a.size();i++)
{
if(a.at(i).nono)
{
flag=1;
double score;
cout << “|” << a.at(i).no << setw(12 - a.at(i).no.size()) << “|” << a.at(i).name << setw(12 - a.at(i).name.size())
<< “|” << a.at(i).sex << setw(10 - a.at(i).sex.size()) <<"|"<<a.at(i).age<<setw(10-a.at(i).age.size())<< “|” << a.at(i).math << setw(8 - get_width(a.at(i).math))
<< “|” << a.at(i).English << setw(8 - get_width(a.at(i).English)) << “|” << a.at(i).C
<< setw(8 - get_width(a.at(i).C)) << “|” << a.at(i).sum << setw(8 - get_width(a.at(i).sum))
<< “|” << a.at(i).aver << endl;
cout << “--------------------------------------------------------------------------” << endl;
cout<<“请输入你想修改那项成绩:”<<endl;
cout<<“1、高数”<<endl;
cout<<“2、C”<<endl;
cout<<“3、English”<<endl;
cin>>num;
if(num"1")
{
cout<<“请输入正确的高数成绩:”;
cin>>score;
a.at(i).math=score;
a.at(i).sum=a.at(i).math+a.at(i).C+a.at(i).English;
a.at(i).aver=a.at(i).sum/3;
}
else
if(num==“2”)
{
cout<<“请输入正确的计算机成绩:”;
cin>>score;
a.at(i).C=score;
a.at(i).sum=a.at(i).math+a.at(i).C+a.at(i).English;
a.at(i).aver=a.at(i).sum/3;
}
else
if(num==“3”)
{
cout<<“请输入正确的英语成绩:”;
cin>>score;
a.at(i).English=score;
a.at(i).sum=a.at(i).math+a.at(i).C+a.at(i).English;
a.at(i).aver=a.at(i).sum/3;
}
else
{
cout<<“输入有误!请重新输入”<<endl;
}
}
}
if(flag0)
{
cout<<“没有查找到该同学!”<<endl;
}
}
void deletew(vector &a,string t)
{
int m=0;
for(vector ::size_type i=0;i<a.size();i++)
{
if(a.at(i).not)
{
m=1;
a.at(i).no =“0”;
break;
}
}
if(m=0)
{
cout<<“没有找到该同学!”<<endl;
}
else
{
cout<<“此同学信息已删除!”<<endl;
}
}
void search(vector &a,string t)
{
int flag=0;
string ino, iname, isex,iage, math, English, c, sum, aver;
ino = “|学号”; iname = “|姓名”; isex = “|性别”;iage="|年龄"; math = “|数学”;
English = “|英语”; c = “|计算机”; sum = “|总分”; aver = “|平均分”;
cout << ino << " " << iname << " " << isex << " “<<iage<<” "
<< math << " " << English << " " << c << " " << sum << " " << aver << endl;
cout << “--------------------------------------------------------------------------” << endl;
for(vector ::size_type i=0;i<a.size();i++)
{
if(a.at(i).not)
{
flag=1;
double score;
cout << “|” << a.at(i).no << setw(12 - a.at(i).no.size()) << “|” << a.at(i).name << setw(12 - a.at(i).name.size())
<< “|” << a.at(i).sex << setw(10 - a.at(i).sex.size()) <<"|"<<a.at(i).age<<setw(10-a.at(i).age.size())<< “|” << a.at(i).math << setw(8 - get_width(a.at(i).math))
<< “|” << a.at(i).English << setw(8 - get_width(a.at(i).English)) << “|” << a.at(i).C
<< setw(8 - get_width(a.at(i).C)) << “|” << a.at(i).sum << setw(8 - get_width(a.at(i).sum))
<< “|” << a.at(i).aver << endl;
cout << “--------------------------------------------------------------------------” << endl;
}
}
if(flag=0)
{
cout<<“没有查找到该同学!”<<endl;
}
}
void sorting(vector &a,string subject,string order)
{
int flag=0;
if(subject"1")
{
if(order==“1”)
{
sort(a.begin(),a.end(),downorder_math);
}
else
if(order==“2”)
{
sort(a.begin(),a.end(),uporder_math);
}
else
{
flag=1;
cout<<“输入错误,请重新输入!”;
}
}
else
if(subject==“2”)
{
if(order==“1”)
{
sort(a.begin(),a.end(),downorder_C);
}
else
if(order==“2”)
{
sort(a.begin(),a.end(),uporder_C);
}
else
{
flag=1;
cout<<“输入错误,请重新输入!”;
}
}
else
if(subject==“3”)
{
if(order==“1”)
{
sort(a.begin(),a.end(),downorder_English);
}
else
if(order==“2”)
{
sort(a.begin(),a.end(),uporder_English);
}
else
{
flag=1;
cout<<“输入错误,请重新输入!”;
}
}
else
if(subject==“4”)
{
if(order==“1”)
{
sort(a.begin(),a.end(),downorder_sum);
}
else
if(order==“2”)
{
sort(a.begin(),a.end(),uporder_sum);
}
else
{
flag=1;
cout<<“输入错误,请重新输入!”;
}
}
else
{
flag=1;
cout<<“排序的科目输入错误!请重新输入”<<endl;
}
if(flag==0)
{
print(a);
}
}
void count(vector &a)
{
int number,number_m=0,number_C=0,number_e=0,number_s=0;
double number_ma=0,number_Ca=0,number_ea=0,number_sa=0;
int number_uma=0,number_uCa=0,number_uea=0,number_usa=0;
for(vector ::size_type i=0;i<a.size();i++)
{
if(a.at(i).no!=“0”)
{
number++;
number_ma+=a.at(i).math;
number_Ca+=a.at(i).C;
number_ea+=a.at(i).English;
if(a.at(i).math<60)
{
number_m++;
}
if(a.at(i).C<60)
{
number_C++;
}
if(a.at(i).English<60)
{
number_e++;
}
}
}
number_ma/=number;
number_Ca/=number;
number_ea/=number;
for(vector ::size_type i=0;i<a.size();i++)
{
if(a.at(i).no!=“0”)
{
if(a.at(i).math<number_ma)
{
number_uma++;
}
if(a.at(i).C<number_Ca)
{
number_Ca++;
}
if(a.at(i).English<number_ea)
{
number_ea++;
}
}
}
cout<<“统计结果如下:”<<endl;
cout << " \t平均分\t不及格人数\t及格人数\t低于平均分人数\t高于平均分人数" << endl;
cout << “高数:\t” <<number_ma << "\t " << number_m << "\t\t " << number - number_m << "\t\t "
<<number_uma<< "\t\t " << number - number_uma<< endl;
cout << “英语:\t” << number_ea<< "\t " << number_e << "\t\t " << number - number_e << "\t\t "
<< number_uea << "\t\t " << number - number_uea<< endl;
cout << "计算机: " << number_Ca << "\t " << number_C<< "\t\t " << number - number_C<< "\t\t "
<< number_uCa << "\t\t " << number - number_uCa<< endl;
}
bool uporder_math(const student &stu1,const student &stu2)
{
return stu1.math<stu2.math;
}
bool uporder_C(const student &stu1,const student &stu2)
{
return stu1.C<stu2.C;
}
bool uporder_English(const student &stu1,const student &stu2)
{
return stu1.English<stu2.English;
}
bool uporder_sum(const student &stu1,const student &stu2)
{
return stu1.sum<stu2.sum;
}
bool downorder_math(const student &stu1,const student &stu2)
{
return stu1.math>stu2.math;
}
bool downorder_C(const student &stu1,const student &stu2)
{
return stu1.C>stu2.C;
}
bool downorder_English(const student &stu1,const student &stu2)
{
return stu1.English>stu2.English;
}
bool downorder_sum(const student &stu1,const student &stu2)
{
return stu1.sum>stu2.sum;
}
void grade(vector &a)
{
}
本文档详细介绍了使用C++编程实现一个学生信息管理系统的过程,包括登录动画、主菜单选项、输入学生信息、显示信息、查询、删除、排序和统计等功能。系统采用vector向量、结构体和文件流进行数据管理,同时运用了sort函数进行成绩排序。
3323

被折叠的 条评论
为什么被折叠?



