c++课程设计(水)

时间:2022-12-16 17:01:16

图书管理系统:

百度来源

#include<string.h>
#include <iostream>
#include <iomanip>
#include <string>
#include <fstream>//输入/输出文件流类
using namespace std;
const int Maxr=100;//最多的读者
const int Maxb=100;//最多的图书
const int Maxzf=5;//每位读者最多借五本书
//读者类,实现对读者的信息的描述

class Reader
{
private:
int tag;
//删除标记 1:已删 0:未删
int no;
//读者编号
char name[10];
//读者姓名
int zfbook[Maxzf];//所借图书
public:
Reader() {}
char *getname()
{
return name;
} //获取姓名
int gettag()
{
return tag;
} //获取删除标记
int getno()
{
return no;
}//获取读者编号
void setname(char na[])//设置姓名
{
strcpy(name,na);
}
void delbook()
{
tag=1; //设置删除标记 1:已删 0:未删
}
void addreader(int n,char *na)//增加读者
{
tag=0;
no=n;
strcpy(name,na);
for(int i=0; i<Maxzf; i++)
zfbook[i]=0;

}
void zfrowbook(int bookid)//借书操作
{
for(int i=0; i<Maxzf; i++)
{
if (zfbook[i]==0)
{
zfbook[i]=bookid;
return;
}
}
}
int retbook(int bookid)//还书操作
{
for(int i=0; i<Maxzf; i++)
{
if(zfbook[i]==bookid)
{
zfbook[i]=0;
return 1;
}
}
return 0;

}
void disp()//读出读者信息

{
cout << setw(5) << no <<setw(10) << name<<"借书编号:[";
for(int i=0; i<Maxzf; i++)
if(zfbook[i]!=0)
cout << zfbook[i] << "|";
cout << "]"<<endl;
}
};
//读者类库,实现建立读者的个人资料
class RDatabase
{

private:
int top;
//读者记录指针
Reader read[Maxr];//读者记录
public:
RDatabase() //构造函数,将reader.txt读到read[]中
{
Reader s;
top=-1;
fstream file("reader.txt",ios::in);//打开一个输入文件
while (1)
{
file.read((char *)&s,sizeof(s));
if (!file)break;
top++;
read[top]=s;

}
file.close();
//关闭 reader.txt
}
void clear()//删除所有读者信息

{
top=-1;

}
int addreader(int n,char *na)//添加读者时先查找是否存在
{
Reader *p=query(n);
if (p==NULL)
{
top++;
read[top].addreader(n,na);
return 1;

}
return 0;
}
Reader *query(int readerid)//按编号查找
{
for (int i=0; i<=top; i++)
if (read[i].getno()==readerid &&read[i].gettag()==0)
{
return &read[i];

}
return NULL;

}
void disp()//输出所有读者信息
{
for (int i=0; i<=top; i++)
read[i].disp();
}
void readerdata();//读者库维护
~RDatabase() //析构函数,将read[]写到reader.txt文件中
{
fstream file("reader.txt",ios::out);
for (int i=0; i<=top; i++)
if (read[i].gettag()==0)
file.write((char *)&read[i],sizeof(read[i]));
file.close();
}
};
void RDatabase::readerdata()
{
char choice;
char rname[20];
int readerid;
Reader *r;
while (choice!='0')
{
cout <<"\n\n\t\t\t读 者维 护\n\n\n\t\t 1 新 增\n\n\t\t 2 更 改\n\n\t\t 3 删 除\n\n\t\t 4 查 找\n\n\t\t 5 显 示\n\n\t\t 6 全 删\n\n\t\t 0 退 出"<<endl;
cin >> choice;
switch (choice)
{
case '1':
cout << "输入读者编号:";
cin >> readerid;
cout << "输入读者姓名:";
cin >> rname;
addreader (readerid,rname);
break;
case '2':
cout << "输入读者编号:";
cin >> readerid;
r=query(readerid);
if (r==NULL)
{
cout << " 该读者不存在 "<<endl;
break;

}
cout << "输入读者姓名:";
cin >> rname;
r->setname(rname);
break;
case '3':
cout << " 输入读者编号:";
cin >> readerid;
r=query(readerid);
if (r==NULL)
{
cout <<" No this people" << endl;
break;

}
r->delbook();
break;
case '4':
cout << "读入读者编号:";
cin >> readerid;
r=query(readerid);
if (r==NULL)
{
cout <<"该读者不存在"<< endl;
break;

}
r->disp();
break;
case '5':
disp();
break;
case '6':
clear();
break;
default:
cout<<"输入错误请重新输入:";
break;
}

}
}


//图书类,实现对图书的描述,图书的编号,书名,借出,还入等
class Book
{
private:
int tag;//删除标记 1:已删 0:未删
int no;//图书编号
char name[20];//书名
int onshelf;//是否再架 1:再架 2:已借
public:
Book() {}
char *getname()
{
return name; //获取姓名
}
int getno()
{
return no; //获取图书编号
}
int gettag()
{
return tag; //获取删除标记
}
void setname(char na[])//设置书名
{
strcpy(name,na);

}
void delbook()
{
tag=1; //删除图书
}
void addbook(int n,char *na)//增加图书
{
tag=0;
no=n;
strcpy(name,na);
onshelf=1;
}
int zfrowbook()//借书操作
{
if (onshelf==1)
{
onshelf=0;
return 1;
}
return 0;
}
void retbook()//还书操作
{
onshelf=1;

}
void disp()//输出图书
{
cout << setw(6) << no << setw(18) << name << setw(10)<<(onshelf==1?"在架":"已借") <<endl;

}
};


//图书库类,实现对图书的维护,查找,删除等
class BDatabase
{
private:
int top;
//图书记录指针
Book book[Maxb]; //图书记录
public:
BDatabase()//构造函数,将book.txt读到book[]中

{
Book b;
top=-1;
fstream file("book.txt",ios::in);
while (1)
{
file.read((char *)&b,sizeof(b));
if (!file) break;
top++;
book[top]=b;
}
file.close();

}
void clear()//全删
{
top=-1;

}
int addbook(int n,char *na)//增加图书
{
Book *p=query(n);
if (NULL==p)
{
top++;
book[top].addbook(n,na);
return 1;
}
return 0;
}
Book *query(int bookid)//查找图书
{
for (int i=0; i<=top; i++)
if (book[i].getno()==bookid &&book[i].gettag()==0)
{

return &book[i];
}
return NULL;
}
void bookdata();//图书库维护
void disp()
{
for (int i=0; i<=top; i++)
if (book[i].gettag()==0)
book[i].disp();
}
~BDatabase()//析构函数,将book[]写到book.txt文件中
{
fstream file("book.txt",ios::out);
for (int i=0; i<=top; i++)
if (book[i].gettag()==0)
file.write((char *)&book[i],sizeof(book[i]));
file.close();
}
};
void BDatabase::bookdata()
{
char choice;
char bname[40];
int bookid;
Book *b;
while (choice!='0')
{
cout <<"\n\n\n\t\t\t图 书 维 护 "<<endl<<endl;
cout<<"\t\t1 新 增\n \t\t2 更 改\n\t\t3 删 除\n\t\t4 查 找\n\t\t5 显 示\n\t\t6 全 删\n\t\t0 退 出"<<endl;
cin >> choice;
switch (choice)
{
case '1':
cout << "输入图书编号:"<<endl;
cin >> bookid;
cout << "输入图书书名:"<<endl;
cin >> bname;
addbook(bookid,bname);
break;
case '2':
cout << "输入图书编号:"<<endl;
cin >> bookid;
b=query(bookid);
if (b==NULL)
{cout << " 该图书不存在 "<<endl;
break;
}
cout << "输入新的书名:"<<endl;
cin >> bname;
b->setname(bname);
break;
case '3':
cout <<" 读入图书编号:"<<endl;
cin >> bookid;
b=query(bookid);
if (b==NULL)
{
cout <<" 该图书不存在" << endl;
break;
}
b->delbook();
break;
case '4':
cout << " 读入图书编号:"<<endl;
cin >> bookid;
b=query(bookid);
if (b==NULL)
{
cout <<" 该图书不存在"<< endl;
break;
}
b->disp();
break;
case '5':
disp();
break;
case '6':
clear();
break;
default:
cout<<"输入错误,请从新输入:";

}

}
}

//main() 函数的实现,程序的主界面的引导
int main()
{

char choice;
int bookid,readerid;
RDatabase ReaderDB;
Reader *r;
BDatabase BookDB;
Book *b;
while(choice!='0')
{
cout <<endl<<endl<<"\t\t\t图 书 管 理 系 统\n\n\n";

cout <<"\t\t\t1 借 书\n\n\t\t\t2 还 书 \n\n\t\t\t3 图 书 维 护\n\n\t\t\t4 读 者 维 护\n\n\t\t\t0 离 开"<<endl;
cin >> choice;
switch (choice)
{
case '1':
cout <<" 借书 读者编号:";
cin >>readerid;
cout <<" 图书编号: ";
cin >>bookid;
r=ReaderDB.query(readerid);//按编号查找
if (NULL==r)
{
cout <<" 不存在该读者,不能借书"<< endl;
break;

}
b=BookDB.query(bookid);
if (b==NULL)
{
cout <<" 不存在该图书,不能借书"<< endl;
break;

}
if (b->zfrowbook()==0)
{
cout << " 该图书已借出,不能借书"<< endl;
break;

}
r->zfrowbook(b->getno());
break;
case '2':
cout<<"还书\n 读者编号:";
cin >>readerid;
cout << " 图书编号:";
cin >>bookid;
r=ReaderDB.query(readerid);
if (r==NULL)
{
cout <<" 不存在该读者,不能还书" << endl;
break;

}
b=BookDB.query(bookid);
if (b==NULL)
{
cout <<" 不存在该图书,不能还书" <<endl;
break;

}
b->retbook();
r->retbook(b->getno());
break;
case '3':
BookDB.bookdata();
break;
case '4':
ReaderDB.readerdata();
break;
default:
cout<<"输入错误,请从新输入:";

}

}
}
职工管理系统:

百度参考:(主要架构是百度的)

#include<iostream>
#include<string.h>
#include<fstream>
#include<stdlib.h>
#include<stdio.h>
using namespace std;
#define N 100
int f=0;
string p;
void menu();
class Worker
{
string num,name,sex,edu,address,tel;
int age,salary;
public:
Worker() {}
void show();
~Worker() {}
friend class WorkerList;
};
class WorkerList
{
Worker w[N];
int NUM;//职工数目
int count;//当前职工th
public:
void add();
void Sort();
void Search();
void dele();
void modify();
void save();
void disp();
WorkerList()
{
NUM=0;
count=0;
}
};
void menu()
{
cout<<endl;
cout<<"****************************************"<<endl;
cout<<"| |"<<endl;
cout<<"| 职工管理系统、 |"<<endl;
cout<<"| 1.职工信息添加 |"<<endl;
cout<<"| 2.职工信息修改 |"<<endl;
cout<<"| 3.职工信息删除 |"<<endl;
cout<<"| 4.职工信息排序 |"<<endl;
cout<<"| 5.职工信息查找 |"<<endl;
cout<<"| 6.职工信息显示 |"<<endl;
cout<<"| 7.职工信息保存 |"<<endl;
cout<<"| 0.退出系统 |"<<endl;
cout<<"****************************************"<<endl;
cout<<endl;
}
void domain()
{
WorkerList wl;
while(1)
{
system("cls");
menu();
cout<<"请选择操作编号0~7"<<endl;
int i1;
cin>>i1;
while(!(i1>=0&&i1<=7))
{
cout<<""<<endl;
cin>>i1;
}
switch(i1)
{
case 1:
wl.add();
break;
case 2:
wl.modify();
break;
case 3:
wl.dele();
break;
case 4:
wl.Sort();
break;
case 5:
wl.Search();
break;
case 6:
wl.disp();
break;
case 7:
wl.save();
break;
case 0:
cout<<"系统退出"<<endl;
exit(0);
default:
break;
}

}
cout<<"是否返回主菜单?Y/N"<<endl;
cin>>p;
if(p=="n"||p=="N")
{
cout<<"系统退出!"<<endl;
exit(0);
}
}
void WorkerList::add()
{
cout<<"输入职工信息:"<<endl;
cout<<"工号:";
string num;
cin>>num;
for(int i=0; i<NUM; i++)
while(num==w[i].num)
{
cout<<"此职工编号已经存在,请重新输入"<<endl;
cout<<"工号:";
cin>>num;
}
w[NUM].num=num;
cout<<"姓名:";
cin>>w[NUM].name;
cout<<"性别:";
cin>>w[NUM].sex;
cout<<"学历:";
cin>>w[NUM].edu;
cout<<"学龄:";
cin>>w[NUM].age;
cout<<"工资:";
cin>>w[NUM].salary;
cout<<"地址:";
cin>>w[NUM].address;
cout<<"电话:";
cin>>w[NUM].tel;
++NUM;
count=NUM;
cout<<"请按任意键继续"<<endl;
getchar();
getchar();
}
void Worker::show()
{
cout<<"工号:"<<num<<endl;
cout<<"姓名:"<<name<<endl;
cout<<"性别:"<<sex<<endl;
cout<<"学历:"<<edu<<endl;
cout<<"年龄:"<<age<<endl;
cout<<"工资:"<<salary<<endl;
cout<<"地址:"<<address<<endl;
cout<<"电话:"<<tel<<endl;
cout<<endl;
}
void WorkerList::modify()
{
if(NUM<=0)
{
cout<<"没有职工信息存入,即将返回主菜单"<<endl;
menu();
}
cout<<"请输入需要修改信息的职工编号"<<endl;
string num1;
cin>>num1;
int j=0,k;
int flag=1;
while(flag)
{
for(; j<count; j++)
{
if(num1==w[j].num)
{
flag=0;
k=j;
break;
}
}
if(flag)
{
cout<<"不存在此员工,请重新输入:"<<endl;
j=0;
cin>>num1;
}
cout<<"你选择的职工信息如下:"<<endl;
cout<<" 工号:"<<w[k].num<<endl;
cout<<" 姓名:"<<w[k].name<<endl;
cout<<" 性别:"<<w[k].sex<<endl;
cout<<" 学历:"<<w[k].edu<<endl;
cout<<" 年龄:"<<w[k].age<<endl;
cout<<" 工资:"<<w[k].salary<<endl;
cout<<" 地址:"<<w[k].address<<endl;
cout<<" 电话:"<<w[k].tel<<endl;
cout<<endl;
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<<" 0.返回主菜单 "<<endl;
cout<<"**************************"<<endl;
cout<<endl;
cout<<"请选择数字编号0~8"<<endl;
int i3;
cin>>i3;
while(i3<0&&i3>8)
{
cout<<"输入有误,请重新输入:"<<endl;
cin>>i3;
}
switch(i3)
{
case 1:
cout<<"请输入新的职工工号:";
cin>>w[k].num;
cout<<"修改信息已保存,现返回主菜单:请按任意键"<<endl;
getchar();
getchar();
menu();
menu();
break;
case 2:
cout<<"请输入新的职工姓名:";
cin>>w[k].name;
cout<<"修改信息已保存,现返回主菜单:请按任意键"<<endl;
getchar();
getchar();
menu();
break;
case 3:
cout<<"请输入新的职工性别:";
cin>>w[k].sex;
cout<<"修改信息已保存,现返回主菜单:请按任意键"<<endl;
getchar();
getchar();
menu();
menu();
break;
case 4:
cout<<"请输入新的职工学历:";
cin>>w[k].edu;
cout<<"修改信息已保存,现返回主菜单:请按任意键"<<endl;
getchar();
getchar();
menu();
break;
case 5:
cout<<"请输入新的职工年龄:";
cin>>w[k].age;
cout<<"修改信息已保存,现返回主菜单:请按任意键"<<endl;
getchar();
getchar();
menu();
break;
case 6:
cout<<"请输入新的职工工资:";
cin>>w[k].salary;
cout<<"修改信息已保存,现返回主菜单:请按任意键"<<endl;
getchar();
getchar();
menu();
break;
case 7:
cout<<"请输入新的职工地址:";
cin>>w[k].address;
cout<<"修改信息已保存,现返回主菜单:请按任意键"<<endl;
getchar();
getchar();
menu();
break;
case 8:
cout<<"请输入新的职工电话:";
cin>>w[k].tel;
cout<<"修改信息已保存,现返回主菜单:请按任意键"<<endl;
getchar();
getchar();
menu();
break;
case 0:
menu();
default:
break;
}
}
}
void WorkerList::disp()
{
if(NUM<=0)
{
cout<<"No this people"<<endl;
menu();
}
else
cout<<"已保存的职工信息如下:"<<endl;
for(int i=0; i<count; i++)
{
cout<<"************************"<<endl;
cout<<"工号:"<<w[i].num<<endl;
cout<<"姓名:"<<w[i].name<<endl;
cout<<"性别:"<<w[i].sex<<endl;
cout<<"学历:"<<w[i].edu<<endl;
cout<<"年龄:"<<w[i].age<<endl;
cout<<"工资:"<<w[i].salary<<endl;
cout<<"地址:"<<w[i].address<<endl;
cout<<"电话:"<<w[i].tel<<endl;
cout<<"************************"<<endl;
}
cout<<"请按任意键继续"<<endl;
getchar();
getchar();
}
void WorkerList::Search()
{
if(NUM<=0)
{
cout<<"没有职工信息存入,即将返回主菜单"<<endl;
menu();
}
else
{
cout<<"*************************"<<endl;
cout<<"** 查找方式: **"<<endl;
cout<<"** 1.按工号查找 **"<<endl;
cout<<"** 2.按姓名查找 **"<<endl;
cout<<"** 3.按学历查找 **"<<endl;
cout<<"** 0.返回主菜单 **"<<endl;
cout<<"*************************"<<endl;
cout<<endl;
int i4;
cin>>i4;
while(i4<0||i4>3)
{
cout<<"输入错误,请重新输入:"<<endl;
cin>>i4;
}
if(i4==1)
{
string num2;
cout<<"请输入要查询的职工的工号:"<<endl;
cin>>num2;
int j=0,k;
int flag=1;
while(flag)
{
for(; j<count; j++)
{
if(num2==w[j].num)
{
flag=0;
k=j;
cout<<"查询的职工信息如下:"<<endl;
cout<<" 工号:"<<w[j].num<<endl;
cout<<" 姓名:"<<w[j].name<<endl;
cout<<" 性别:"<<w[j].sex<<endl;
cout<<" 学历:"<<w[j].edu<<endl;
cout<<" 年龄:"<<w[j].age<<endl;
cout<<" 工资:"<<w[j].salary<<endl;
cout<<" 地址:"<<w[j].address<<endl;
cout<<" 电话:"<<w[j].tel<<endl;
cout<<"请按任意键继续"<<endl;
getchar();
getchar();
break;
}
}
if(flag)
{
flag=0;
cout<<"不存在此职工!!"<<endl;
break;
}
}
}
else if(i4==2)
{
string name2;
cout<<"请输入要查询的职工的姓名:"<<endl;
cin>>name2;
int j=0,k;
int flag=1;
while(flag)
{
for(; j<count; j++)
{
if(name2==w[j].name)
{
flag=0;
k=j;
cout<<"查询的职工信息如下:"<<endl;
cout<<" 工号:"<<w[j].num<<endl;
cout<<" 姓名:"<<w[j].name<<endl;
cout<<" 性别:"<<w[j].sex<<endl;
cout<<" 学历:"<<w[j].edu<<endl;
cout<<" 年龄:"<<w[j].age<<endl;
cout<<" 工资:"<<w[j].salary<<endl;
cout<<" 地址:"<<w[j].address<<endl;
cout<<" 电话:"<<w[j].tel<<endl;
cout<<"请按任意键继续"<<endl;
getchar();
getchar();
break;
}
}
if(flag)
{
flag=0;
cout<<"不存在此职工!!"<<endl;
break;
}
}
}
else if(i4==3)
{
string edu2;
cout<<"请输入要查询的职工的学历:"<<endl;
cin>>edu2;
int j=0,k;
int flag=1;
while(flag)
{
for(; j<count; j++)
{
if(edu2==w[j].edu)
{
flag=0;
k=j;
cout<<"查询的职工信息如下:"<<endl;
cout<<" 工号:"<<w[j].num<<endl;
cout<<" 姓名:"<<w[j].name<<endl;
cout<<" 性别:"<<w[j].sex<<endl;
cout<<" 学历:"<<w[j].edu<<endl;
cout<<" 年龄:"<<w[j].age<<endl;
cout<<" 工资:"<<w[j].salary<<endl;
cout<<" 地址:"<<w[j].address<<endl;
cout<<" 电话:"<<w[j].tel<<endl;
cout<<"请按任意键继续"<<endl;
getchar();
getchar();
break;
}
}
if(flag)
{
flag=0;
cout<<"不存在此职工!!"<<endl;
break;
}
}
}
else if(i4==0)
menu();
}
}
void WorkerList::Sort()
{
if(NUM<=0)
{
cout<<"没有职工信息存入,系统将返回主菜单"<<endl;
menu();
}
else
{
cout<<"****************************"<<endl;
cout<<"** 查找方式: **"<<endl;
cout<<"** 1.按工资排序(升序)**"<<endl;
cout<<"** 2.按工资排序(降序)**"<<endl;
cout<<"** 0.返回主菜单 **"<<endl;
cout<<"****************************"<<endl;
cout<<endl;

int i5;
cin>>i5;
while(i5<0||i5>2)
{
cout<<"输入有误,请重新输入"<<endl;
cin>>i5;
}
if(i5==1)
{
for(int i=0; i<count-1; i++)
for(int j=i+1; j<count-1; j++)
{
if(w[j].salary>w[j+1].salary)
{
Worker temp;
temp=w[j];
w[j]=w[j+1];
w[j+1]=temp;
}
}
cout<<"按工资升序后的信息如下:"<<endl;
for(int i=0; i<count; i++)
{
cout<<"************************"<<endl;
cout<<"工号:"<<w[i].num<<endl;
cout<<"姓名:"<<w[i].name<<endl;
cout<<"性别:"<<w[i].sex<<endl;
cout<<"学历:"<<w[i].edu<<endl;
cout<<"年龄:"<<w[i].age<<endl;
cout<<"工资:"<<w[i].salary<<endl;
cout<<"地址:"<<w[i].address<<endl;
cout<<"电话:"<<w[i].tel<<endl;
cout<<"************************"<<endl;
}
}
else if(i5==2)
{
for(int i=0; i<count-1; i++)
for(int j=i+1; j<count-1; j++)
{
if(w[j].salary<w[j+1].salary)
{
Worker temp;
temp=w[j];
w[j]=w[j+1];
w[j+1]=temp;
}
}
cout<<"按工资升序后的信息如下:"<<endl;
for(int i=0; i<count; i++)
{
cout<<"************************"<<endl;
cout<<"工号:"<<w[i].num<<endl;
cout<<"姓名:"<<w[i].name<<endl;
cout<<"性别:"<<w[i].sex<<endl;
cout<<"学历:"<<w[i].edu<<endl;
cout<<"年龄:"<<w[i].age<<endl;
cout<<"工资:"<<w[i].salary<<endl;
cout<<"地址:"<<w[i].address<<endl;
cout<<"电话:"<<w[i].tel<<endl;
cout<<"************************"<<endl;
}
}
else if(i5==0)
menu();
}
}
void WorkerList::dele()
{
if(NUM<=0)
{
cout<<"没有职工信息存入,系统将返回主菜单"<<endl;
menu();
}
cout<<"请输入要删除信息职工的工号:"<<endl;
string num3;
cin>>num3;
int j=0,k;
int flag=1;
while(flag)
{
for(; j<count; j++)
{
if(num3==w[j].num)
{
flag=0;
k=j;
break;
}
}
if(flag)
{
cout<<"不存在此员工,请重新输入:"<<endl;
j=0;
cin>>num3;
}
cout<<"你选择的职工信息如下:"<<endl;
cout<<" 工号:"<<w[k].num<<endl;
cout<<" 姓名:"<<w[k].name<<endl;
cout<<" 性别:"<<w[k].sex<<endl;
cout<<" 学历:"<<w[k].edu<<endl;
cout<<" 年龄:"<<w[k].age<<endl;
cout<<" 工资:"<<w[k].salary<<endl;
cout<<" 地址:"<<w[k].address<<endl;
cout<<" 电话:"<<w[k].tel<<endl;
cout<<endl;
cout<<"确认删除请输入Y,返回主菜单请输入N"<<endl;
string p;
cin>>p;
while(1)
{
if(p=="y"||p=="Y")
{
cout<<"员工信息已删除!"<<endl;
for(int i=0; i<count; i++)
if(w[i].num==num3)
int j=i;
for(; j<=count-1; j++)
w[j]=w[j+1];
count--;
break;
}
else if(p=="n"||p=="N")
{
menu();
}
else
{
cout<<"输入有误,请重新输入:"<<endl;
cin>>p;
}
}

}
}
void WorkerList::save()
{
if(NUM<=0)
{
cout<<"没有职工信息存入,即将返回主菜单:"<<endl;
menu();
}
else
{
ofstream fout;
fout.open("D:\\Worker.txt",ios::out);
cout<<"文件正在保存....请稍后!!"<<endl;
cout<<"数据保存成功"<<endl;
fout<<"已保存员工信息如下:"<<endl;
for(int i=0; i<count; i++)
{
fout<<"****************"<<endl;
fout<<"工号: "<<w[i].num<<endl;
fout<<"姓名: "<<w[i].name<<endl;
fout<<"性别:"<<w[i].sex<<endl;
fout<<"学历:"<<w[i].edu<<endl;
fout<<"年龄:"<<w[i].age<<endl;
fout<<"工资:"<<w[i].salary<<endl;
fout<<"地址:"<<w[i].address<<endl;
fout<<"电话:"<<w[i].tel<<endl;
fout<<"****************"<<endl;
}
}
}
int main()
{
domain();
return 0;
}