谁会用C语言编一个职工信息管理系统

要求:编写一个图书管理借阅管理的程序。由键盘输入(最好要考虑输入数据输入的格式及输入数据的有效性),然后进行以下的功能实现。程序要求主函数是一个功能选择菜单,其它各功能都用各自的函数实现。要求至少有5个职工的原始数据。原始数据如下:职工号 姓名 性别 年龄 学历 工资 住址 电话0001 王.. 男 25 本科 2000 南京 025-521300010002 张.. 女 28 研究生 2500 南京 025-51234567…功能要求如下:1、系统以菜单方式工作 2、职工信息录入功能(职工信息用文件保存) 3、职工信息浏览功能 4、职工信息查询功能,查询方式(可选项(1)或(2)): (1)按学历查询 (2)按职工号查询 5、职工信息删除,修改功能(可选项)。

本人有一个写的非常相似的程序,需要修改的话
[email protected]
#include<stdlib.h>
#include<conio.h>
#include<time.h>
#include<iostream.h>
#include<windows.h>
#include<fstream.h>
#include<stdio.h>
#include<string.h>
class employee{
private:
int b_year;
int b_month;
bool wedding;
bool gender; //性别
int seniority;//工作年限
char education[6];//学历
char phone[15];
public:
long number;//职员编号
char name[10];
employee();//构造函数,用于对职工所有成员初始化
void readfile(ifstream &fin);//从文件中读入已存在的职工信息
void display();//输出本职工信息
void amend();//修改职工信息
void readstdin();//从键盘读入新建一个员工
void writefile(ofstream &fout);//向文件写入职工的信息
};
class S_list{
public:
employee emp;
S_list *next;
S_list(){
next=NULL;}//构造函数,用于对职工链表头结点初始化,以及所有成员初始化
//头结点里面的元素可以用作特殊用途
//friend void M_writefile(ofstream &fout,S_list &star);
//friend void M_readfile(ifstream &fin,S_list &star);
//friend void M_display(S_list &star,int n);//输出n个员工的基本信息,当n=0时,全部输出n=1时,查看当前员工的基本信息
S_list *search(long num);//从当前指针往下查找给定编号员工,返回其指针
void add(S_list *addnext);//将职工形成链
void del();//删除本联结的下一个元素

};
employee::employee(){
number=0; // 用于统计职工总数
strcpy(name,"合肥汇众");//公司名称
b_year=2007;//公司成立日期
b_month=4;
wedding=true;//暂时无用途
gender=true;//暂时无用途
seniority=0;//暂时无用途
strcpy(education,"ABS");
strcpy(phone,"05518304945");
}

void employee::readfile(ifstream &fin)
{
char c;
fin>>number>>name>>b_year>>b_month;
fin>>c;
if(c=='y'||c=='Y')wedding=true;
else wedding=false;
fin>>c;
if(c=='y'||c=='Y')gender=true;
else gender=false;
fin>>seniority>>education>>phone;}
void employee::writefile(ofstream &fout)
{
fout<<number<<" "<<name<<" "<<b_year<<" "<<b_month<<" ";
if(wedding==true)fout<<"y"<<" ";
else fout<<"n"<<" ";
if(gender==true)fout<<"y"<<" ";
else fout<<"n"<<" ";
fout<<seniority<<" "<<education<<" "<<phone;
}
void employee::display(){
printf("%-9ld%-9s%d-%-5d",number,name,b_year,b_month);
if(wedding==true)printf("是 ");
else printf("否 ");
if(gender==true)printf("男 ");
else printf("女 ");
printf("%-9d%-9s%-9s\n",seniority,education,phone);}
void employee::amend(){
int i;
char c,a[15];
display();
printf("项目编号:%-9d%-9d%-9d%-9d%-9d%-9d%-9d",1,2,3,4,5,6,7);
cout<<"\n请输入需要修改的信息编号:";
cin>>i;
fflush(stdin);
switch(i){
case 1:cout<<"\n请输入正确的职工姓名:";cin>>a;if(a[0]){strcpy(name,a);cout<<"修改成功"<<endl;}else cout<<"修改失败"<<endl;break;
case 2:cout<<"\n请输入正确的出生年月(中间空格隔开):";cin>>b_year>>b_month;cout<<"修改成功"<<endl;break;
case 3:cout<<"\n此员工婚否(Y/N):";cin>>c;if(c=='y'||c=='Y')wedding=true;else wedding=false;cout<<"修改成功"<<endl;break;
case 4:cout<<"\n此员工性别(男Y/女N):";cin>>c;if(c=='y'||c=='Y')gender=true;else gender=false;cout<<"修改成功"<<endl;break;
case 5:cout<<"\n请输入员工工作年限:"; cin>>seniority; cout<<"修改成功"<<endl;break;
case 6:cout<<"\n请输入此员工的学历:";cin>>a;if(a[0]){strcpy(education,a);cout<<"修改成功"<<endl;}else cout<<"修改失败"<<endl;break;
case 7:cout<<"\n请输入此员工的联系方式:";cin>>a;if(a[0]){strcpy(phone,a);cout<<"修改成功"<<endl;}else cout<<"修改失败"<<endl;break;
//default: cout<<"\n输入的编号超出范围,拒绝更改,请确认后再操作"<<endl;
}
}

void employee::readstdin()
{
char c;
cout<<"职员编号:";
fflush(stdin);
cin>>number;
cout<<"\n 姓名:";
fflush(stdin);
cin>>name;
cout<<"\n 出生年月:";
fflush(stdin);
cin>>b_year>>b_month;
cout<<"\n婚否(Y/N):";
fflush(stdin);
cin>>c;
if(c=='y'||c=='Y')wedding=true;
else wedding=false;
cout<<"\n性别(男Y/女N):";
fflush(stdin);
cin>>c;
if(c=='y'||c=='Y')gender=true;
else gender=false;
cout<<"\n工作年限:";
fflush(stdin);
cin>>seniority;
cout<<"\n 学历:";
fflush(stdin);
cin>>education;
cout<<"\n 联系方式:";
fflush(stdin);
cin>>phone;
}
S_list* S_list::search(long num){
S_list *p=this,*q=p;
while(p&&p->emp.number!=num){q=p;p=p->next;}
return q;}
void S_list::add(S_list *addnext){
if(!this->next){
this->next=addnext;
addnext->next=NULL;}
else {
S_list *p;
p=this->next;
this->next=addnext;
addnext->next=p; }
}
void S_list::del(){
if(this->next){
S_list *p;
p=this->next;
this->next=p->next;
cout<<"\n职工: "<<p->emp.name<<" 全部信息从本系统删除成功!!";
delete p;}
else cout<<"\n没有给定的职工信息,无法删除!!"<<endl;
}
void M_display(S_list &star,int n){
S_list *slist=star.next;
if(n==0)n=100;
system("cls");
cout<<"\t\t*****************************************\n";
cout<<"\t\t| 合肥汇众汽车电子技术有限公司 |\n";
cout<<"\t\t*****************************************\n\n\n";
cout<<"编号 姓名 出生日期 婚否 性别 工作年限 学历 联系方式"<<endl;
while(n--&&slist){slist->emp.display();slist=slist->next;}
}
void M_readfile(ifstream &fin, S_list &star){
S_list *p,*slist=☆int i=0;
while(!fin.eof()){ i++ ;
p=new S_list;
p->emp.readfile(fin);
slist->add(p);
slist=p;}
cout<<i;
}
void M_writefile(ofstream &fout,S_list &star){
S_list *p=star.next;
while(p!=NULL){
p->emp.writefile(fout);
p=p->next;
if(p!=NULL)fout<<"\n";
}
}
/*
int main(){
int i=3;
long n;
S_list star,*p,*slist;
ifstream fin("test");

if(!fin){
cout<<"打不开此文件"<<endl;
return 1; }
slist=☆
M_readfile(fin,star);
fin.close();

M_display(star,0);
p=new S_list;
cout<<"\n新建职工信息:";
p->emp.readstdin();
star.add(p);
fflush(stdin);
cout<<"\t\t演示查找,清输入需要删除的职工编号:"<<endl;
cin>>n;
p=star.search(n);
if(p) p->del();
M_display(star,0);
ofstream fout("test");
M_writefile(fout,star);
slist=☆
while(slist->next) slist->del();

return 0;
employee star;
ofstream fout("test");
if(!fout){
cout<<"打不开此文件"<<endl;
return 1;
}

star.readfile();
star.display();
star.writefile(fout);
fout.close();
ifstream fin("test");
if(!fin){
cout<<"此文件打不开"<<endl;
return 1;
}
star.readfile(fin);
fin.close();
system("cls");
cout<<"编号 姓名 出生日期 婚否 性别 工作年限 学历 联系方式"<<endl;

star.display();
cout<<endl;
return 0;
} */
温馨提示:答案为网友推荐,仅供参考
相似回答