1 / 15
文档名称:

学生信息管理系统C 代码.doc

格式:doc   大小:1,133KB   页数:15页
下载后只包含 1 个 DOC 格式的文档,没有任何的图纸或源代码,查看文件列表

如果您已付费下载过本站文档,您可以点这里二次下载

分享

预览

学生信息管理系统C 代码.doc

上传人:beny00001 2022/2/16 文件大小:1.11 MB

下载得到文件列表

学生信息管理系统C 代码.doc

文档介绍

文档介绍:word
word
1 / 15
word
程序执行后的局部效果
,第一次对信息的录入
word
word
2 / 15
word
word
word
3 / 15
exit(1);
}
count++; //添加一个学生信息,当然 count 要 +1
cout<<"请依次输入要添加的学生学号,,性别,专业,班级:"<<endl;
cin>>no>>name>>sex>>special>>clas;
m_no = no;
outfile<<m_no<<"\t";
m_name = name;
outfile<<m_name<<"\t";
m_sex = sex;
outfile<<m_sex<<"\t";
m_special = special;
outfile<<m_special<<"\t";
m_clas = clas;
outfile<<m_clas<<endl;
();
cout<<"已添加成功!"<<endl;
}
//从磁盘读取数据
void Read(string no[],string name[],string sex[],string special[],string clas[])
word
word
9 / 15
word
{
ifstream infile("",ios::in);
if(!infile)
{
cerr<<" open error"<<endl;
exit(1);
}
for(int i=0; i<count; i++) //只读取存放在数组中 但不对其进展相关操作
{
infile>>no[i]>>name[i]>>sex[i]>>special[i]>>clas[i];
}
();
}
//判断某学号的学生是否在数据库中
int Student::Judge(string num)
{
string no[MAX], name[MAX], sex[MAX], special[MAX], clas[MAX];
Read(no, name, sex, special, clas); //调用Read()函数,获取数据,以便等下进展相关数据的判断
for(int i=0; i<count; i++)
{
if(num == no[i])
{
return i; //如果存在,返回其下标
break;
}
}
return -1; //否如此,返回-1
}
//删除某学生信息
void Student::Delete()
{
string num, no[MAX], name[MAX], sex[MAX], special[MAX], clas[MAX];
Read(no, name, sex, special, clas); //读取学生所有数据,
word
word
10 / 15
word
cout<<"请输入你要删除的学生学号:";
cin>>num;
int k = Judge(num); //定义一个k来接收Judge()的返回值,等下用来判断该num是否存在
if(k != -1) //如果k不等于-1, 表示要删除的学生存在
{
ofstream outfile("");
if(!outfile)
{
cerr<<" open error"<<endl;
exit(1);
}
for(int i=0; i<count; i++)
{
if(i != k) //把下标不等于K〔即除了要删的学生外〕其余的数据重新写入磁盘保存
{
outfile<<no[i]<<"\t";
outfile<<name[i]<<"\t";
outfile<<sex[i]<<"\t";
outfile<<special[i]<<"\t";
outfile<<clas[i]<<endl;
}
}
();
count--; //删除一个学生,人数 -1
cout<<"删除成功!"<<endl;
}
else
cout<