#include<iostream.h>
#include<string.h>
struct student
{
int xuehao;
char name[30];
int year;
int mouth;
int day;
char sex;
char zhuanye;
int mobile;
char jianli;
};
void zhujiemian();
void luru(student stu[10],student other);
void chaxun(student stu[10],student other);
void xiugai(student stu[10],student other);
void shanchu(student stu[10],student null);
void paixu(student stu[10],student other);
void liulan(student stu[10]);
void main() //主函数
{
int a;
for(;;) //设置循环,重复使用
{
student stu[10];
student other;
student null;
zhujiemian(); //调用主界面函数
cin>>a;
switch(a) //开关语句,用来调用不同功能的自定义函数
{case 1:luru(stu,other); break;
case 2:chaxun(stu,other);break;
case 3:xiugai(stu,other);break;
case 4:shanchu(stu,null); break;
case 5:paixu(stu,other);break;
case 6:liulan(stu);break;
}
if(a==0) //退出循环,程序结束
break;
}
}
void zhujiemian() //主界面函数
{
cout<<"---------欢迎使用大学生信息管理系统主菜单--------"<<endl;
cout<<"录入学生信息,请选择:1"<<endl;
cout<<"查询学生信息,请选择:2"<<endl;
cout<<"修改学生信息,请选择:3"<<endl;
cout<<"删除学生信息,请选择:4"<<endl;
cout<<"排序学生信息,请选择:5"<<endl;
cout<<"浏览学生信息,请选择:6"<<endl;
cout<<"退出,请选择:0"<<endl;
}
void luru(student stu[10],student other) //第一个功能函数,录入函数
{
cout<<"请输入学号:";cin>>other.xuehao;
cout<<"请输入姓名:";cin>>other.name;
cout<<"请输入出生年份:";cin>>other.year;
cout<<"请输入出生月份:";cin>>other.mouth;
cout<<"请输入出生日期:";cin>>other.day;
cout<<"请输入性别:";cin>>other.sex;
cout<<"请输入专业:";cin>>other.zhuanye;
cout<<"请输入联系电话:";cin>>other.mobile;
cout<<"请输入简介:";cin>>other.jianli;
for(int i=0;i<10;i++)
if(stu[i].xuehao==0)
{
stu[i]=other;
break;
}
cout<<"录入完成"<<endl;
}
void chaxun(student stu[10],student other) //第二个函数,查询函数
{
cout<<'\t'<<"请输入姓名:"<<endl;
cin>>other.name;
for(int i=0;i<10;i++)
if(strcmp(other.name,stu[i].name)==0)
other=stu[i];
cout<<other.xuehao<<'\n'<<other.name<<'\n'<<other.year<<'\n'<<other.mouth<<'\n'<<other.day<<'\n'<<other.sex<<'\n'<<other.mobile<<'\n'<<other.jianli<<endl;
}
void xiugai(student stu[10],student other) //第三个功能函数,修改函数
{
int b;
cout<<'\t'<<"请输入需要修改信息的学生学号:"<<endl;
cin>>b;
for(int i=0;i<10;i++)
if(b==stu[i].xuehao)
{stu[i]=null; break;}
luru(stu,other);
cout<<"修改完成"<<endl;
cout<<stu[i].xuehao<<'\n'<<stu[i].name<<'\n'<<stu[i].year<<'\n'<<stu[i].mouth<<'\n'<<stu[i].day<<'\n'<<stu[i].sex<<'\n'<<stu[i].mobile<<'\n'<<stu[i].jianli<<endl;
}
void shanchu(student stu[10],student null) //第四个功能函数,删除函数
{
int b;
cout<<'\t'<<"请输入要删除的学生信息的学号:"<<endl;
cin>>b;
for(int i=0;i<10;i++)
if(b==stu[i].xuehao)
stu[i]=null;
cout<<"该学生信息已删除"<<endl;
}
void paixu(student stu[10],student other) //第五个功能函数,排序函数
{
for(int i=0;i<10;i++)
for(int j=0;j<10-i+1;j++)
if(stu[i].xuehao>stu[j].xuehao)
{
other=stu[i];
stu[i]=stu[j];
stu[j]=other;
}
cout<<"排序已完成"<<endl;
for(i=0;i<10;i++)
{
cout<<stu[i].xuehao<<'\n'<<stu[i].name<<'\n'<<stu[i].year<<'\n'<<stu[i].mouth<<'\n'<<stu[i].day<<'\n'<<stu[i].sex<<'\n'<<stu[i].mobile<<'\n'<<stu[i].jianli<<endl;
cout<<endl;
}
}
void liulan(student stu[10]) //第六个功能函数,浏览函数
{
cout<<"学号"<<'\t'<<"姓名"<<'\t'<<"年份"<<'\t'<<"月份"<<'\t'<<"日期"<<'\t'<<"性别"<<'\t'<<"电话"<<'\t'<<"简历"<<endl;
for(int i=0;i<10;i++)
{
cout<<stu[i].xuehao<<'\t'<<stu[i].name<<'\t'<<stu[i].year<<'\t'<<stu[i].mouth<<'\t'<<stu[i].day<<'\t'<<stu[i].sex<<'\t'<<stu[i].mobile<<'\t'<<stu[i].jianli<<endl;
cout<<endl;
}
}
#include<string.h>
struct student
{
int xuehao;
char name[30];
int year;
int mouth;
int day;
char sex;
char zhuanye;
int mobile;
char jianli;
};
void zhujiemian();
void luru(student stu[10],student other);
void chaxun(student stu[10],student other);
void xiugai(student stu[10],student other);
void shanchu(student stu[10],student null);
void paixu(student stu[10],student other);
void liulan(student stu[10]);
void main() //主函数
{
int a;
for(;;) //设置循环,重复使用
{
student stu[10];
student other;
student null;
zhujiemian(); //调用主界面函数
cin>>a;
switch(a) //开关语句,用来调用不同功能的自定义函数
{case 1:luru(stu,other); break;
case 2:chaxun(stu,other);break;
case 3:xiugai(stu,other);break;
case 4:shanchu(stu,null); break;
case 5:paixu(stu,other);break;
case 6:liulan(stu);break;
}
if(a==0) //退出循环,程序结束
break;
}
}
void zhujiemian() //主界面函数
{
cout<<"---------欢迎使用大学生信息管理系统主菜单--------"<<endl;
cout<<"录入学生信息,请选择:1"<<endl;
cout<<"查询学生信息,请选择:2"<<endl;
cout<<"修改学生信息,请选择:3"<<endl;
cout<<"删除学生信息,请选择:4"<<endl;
cout<<"排序学生信息,请选择:5"<<endl;
cout<<"浏览学生信息,请选择:6"<<endl;
cout<<"退出,请选择:0"<<endl;
}
void luru(student stu[10],student other) //第一个功能函数,录入函数
{
cout<<"请输入学号:";cin>>other.xuehao;
cout<<"请输入姓名:";cin>>other.name;
cout<<"请输入出生年份:";cin>>other.year;
cout<<"请输入出生月份:";cin>>other.mouth;
cout<<"请输入出生日期:";cin>>other.day;
cout<<"请输入性别:";cin>>other.sex;
cout<<"请输入专业:";cin>>other.zhuanye;
cout<<"请输入联系电话:";cin>>other.mobile;
cout<<"请输入简介:";cin>>other.jianli;
for(int i=0;i<10;i++)
if(stu[i].xuehao==0)
{
stu[i]=other;
break;
}
cout<<"录入完成"<<endl;
}
void chaxun(student stu[10],student other) //第二个函数,查询函数
{
cout<<'\t'<<"请输入姓名:"<<endl;
cin>>other.name;
for(int i=0;i<10;i++)
if(strcmp(other.name,stu[i].name)==0)
other=stu[i];
cout<<other.xuehao<<'\n'<<other.name<<'\n'<<other.year<<'\n'<<other.mouth<<'\n'<<other.day<<'\n'<<other.sex<<'\n'<<other.mobile<<'\n'<<other.jianli<<endl;
}
void xiugai(student stu[10],student other) //第三个功能函数,修改函数
{
int b;
cout<<'\t'<<"请输入需要修改信息的学生学号:"<<endl;
cin>>b;
for(int i=0;i<10;i++)
if(b==stu[i].xuehao)
{stu[i]=null; break;}
luru(stu,other);
cout<<"修改完成"<<endl;
cout<<stu[i].xuehao<<'\n'<<stu[i].name<<'\n'<<stu[i].year<<'\n'<<stu[i].mouth<<'\n'<<stu[i].day<<'\n'<<stu[i].sex<<'\n'<<stu[i].mobile<<'\n'<<stu[i].jianli<<endl;
}
void shanchu(student stu[10],student null) //第四个功能函数,删除函数
{
int b;
cout<<'\t'<<"请输入要删除的学生信息的学号:"<<endl;
cin>>b;
for(int i=0;i<10;i++)
if(b==stu[i].xuehao)
stu[i]=null;
cout<<"该学生信息已删除"<<endl;
}
void paixu(student stu[10],student other) //第五个功能函数,排序函数
{
for(int i=0;i<10;i++)
for(int j=0;j<10-i+1;j++)
if(stu[i].xuehao>stu[j].xuehao)
{
other=stu[i];
stu[i]=stu[j];
stu[j]=other;
}
cout<<"排序已完成"<<endl;
for(i=0;i<10;i++)
{
cout<<stu[i].xuehao<<'\n'<<stu[i].name<<'\n'<<stu[i].year<<'\n'<<stu[i].mouth<<'\n'<<stu[i].day<<'\n'<<stu[i].sex<<'\n'<<stu[i].mobile<<'\n'<<stu[i].jianli<<endl;
cout<<endl;
}
}
void liulan(student stu[10]) //第六个功能函数,浏览函数
{
cout<<"学号"<<'\t'<<"姓名"<<'\t'<<"年份"<<'\t'<<"月份"<<'\t'<<"日期"<<'\t'<<"性别"<<'\t'<<"电话"<<'\t'<<"简历"<<endl;
for(int i=0;i<10;i++)
{
cout<<stu[i].xuehao<<'\t'<<stu[i].name<<'\t'<<stu[i].year<<'\t'<<stu[i].mouth<<'\t'<<stu[i].day<<'\t'<<stu[i].sex<<'\t'<<stu[i].mobile<<'\t'<<stu[i].jianli<<endl;
cout<<endl;
}
}