#include<conio.h>
#include<stdlib.h>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<iostream>
#include<fstream>
using namespace std;
class Info
{
public:
char num[20];//学号
string name;//姓名
string sex;//性别
string age;//年龄
string jiguan;//籍贯
string xibie;//系别
string zhuanye;//专业
string banji;//班级
string phonenum;//电话
string pingjia;//评价
};
class Ave:public Info
{
private:
int English;
int gaoshu;
int mima;
int chengxusheji;
int wuli;
int lisan;
int totalave;
public:
Ave(int E, int g, int m, int c, int w, int l,int t);
friend int ave(Ave &a);
Ave();
friend class Menu;
};
class Menu
{
public:
void LandingPassword();//登陆
void Append();//增加
void Modify();//修改
void Display();//显示
void Search();//查询
void Delete();//删除
void ChengjiDisplay();//显示各科成绩
void Chengjichaxun();//成绩查询
};
int ave(Ave &a)
{
a.totalave=int((a.English+a.gaoshu+a.mima+a.chengxusheji+a.wuli+a.lisan)/6);
return a.totalave;
}
Ave::Ave()
{
totalave=0;
English=0;
gaoshu=0;
mima=0;
chengxusheji=0;
wuli=0;
lisan=0;
totalave=0;
}
Ave::Ave(int E, int g, int m, int c, int w, int l,int t)
{
totalave=t;
English=E;
gaoshu=g;
mima=m;
chengxusheji=c;
wuli=w;
lisan=l;
}
int menu() //菜单选择函数
{
int n; //n记录选择的菜单
system("cls");//清屏
cout<<"\t\t\t\t***@**@**@**@**@***目 录**@**@**@**@**@**@**@***"<<endl;
cout<<"\t\t\t\t "<<endl;
cout<<"\t\t\t\t *---1.学生信息输入-- "<<endl;//输入
cout<<"\t\t\t\t *----------2.学生信息显示-- "<<endl; // 显示 ")
cout<<"\t\t\t\t *---------------3.学生信息查询-- "<<endl;// 查找
cout<<"\t\t\t\t *------4.学生信息修改-- "<<endl;// 修改
cout<<"\t\t\t\t *---5.学生信息删除-- "<<endl;// 删除
cout<<"\t\t\t\t *---------6.学生成绩显示-- "<<endl;// 成绩显示
cout<<"\t\t\t\t *-----7.学生成绩查询-- "<<endl;// 成绩查询
cout<<"\t\t\t\t *---------- 8.退出系统-- "<<endl;// 选择
cout<<"\t\t\t\t "<<endl;
cout<<"\t\t\t\t\tChoose your number(1-8):[ ]\b\b";
while(1)
{
cin>>n;
getchar();
if(n<1&&n>8)
cout<<"\t\t\t\t\tInput error,please input again(1-8):[ ]\b\b";
else
break;
}
return n;
}
void print1() 学生信息输出函数
{
system("color f5");
cout<<"\t学号"<<"\t\t姓名 "<<"\t性别 "<<"\t年龄 "<<"\t籍贯 ";
cout<<"\t系别 "<<"\t专业 "<<"\t班级 "<<"\t电话号码 "<<"\t学期总评"<<endl;
}
void print2()学生成绩输出
{
system("color f5");
cout<<"\t学号"<<"\t\t姓名"<<"\t英语"<<"\t高数"<<"\t密码学";
cout<<"\tC++"<<"\t物理"<<"\t离散"<<"\t平均分"<<"\t学期总评"<<endl;
}
void Menu::Append() //学生信息输入
{
system("color f4");
Info x;
Ave y;
ofstream ofile("inform.txt",ios::out|ios::app);
ifstream ifile("inform.txt",ios::in);
ofstream sfile("chengji.txt",ios::out|ios::app);
string q_name,q_num,q_sex,q_jiguan,q_xibie,q_zhuanye,q_age,q_banji,q_phonenum,q_pingjia;
// double c_English,c_gaoshu,c_mima,c_chengxusheji,c_wuli,c_lisan;
char f;
if(!ofile||!sfile) //判断文件是否为空
{
cout<<"\t\t\t\t\tCan not open the file"<<endl;
getch(); //不回显字符,不需按回车键,等所有输入完毕再输出
exit(1);
}
do
{
cout<<"\t\t\t\t学号:";
cin>>x.num;
while(!ifile.eof())
{
q_num="";
ifile>>q_num>>q_name>>q_sex>>q_age>>q_jiguan>>q_xibie>>q_zhuanye>>q_banji>>q_phonenum>>q_pingjia;
if(q_num.length()==0)
break;
while(x.num==q_num)
{
cout<<"\n\n\t\tThe number you entered already exists,please input again! \n\n"<<endl;
cout<<"\t\t\t\t学号:";
cin>>x.num;
}
}
cout<<"\t\t\t\t姓名:";
cin>>x.name;
cout<<"\t\t\t\t性别(male or female):";
cin>>x.sex;
cout<<"\t\t\t\t年龄:";
cin>>x.age;
cout<<"\t\t\t\t籍贯:";
cin>>x.jiguan;
// cout<<"\t\t\t\t系别:";
x.xibie&
C++版课程设计--学生管理系统代码实现
最新推荐文章于 2024-06-17 00:35:12 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)