学生信息管理系统

##学生信息管理系统
问题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”)
{

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值