欢迎来到天天文库
浏览记录
ID:53672758
大小:46.00 KB
页数:10页
时间:2020-04-05
《简单的职工管理系统设计方案.doc》由会员上传分享,免费在线阅读,更多相关内容在应用文档-天天文库。
1、#include#include#include#include#include#include#include#includeusingnamespacestd;structEmployee{//声明职工的结构作为链表节点。//-----数据域-----stringm_Code;stringm_Name;unsignedshortintm_Year;stringm_Sex;stringm_Post;strin
2、gm_Department;unsignedintm_Wage;//链表节点的指针域---structEmployee*Next;};//-----个人习惯:取别名-------typedefstructEmployeeNode;typedefNode*Link;//-------函数声明-------------LinkCreate(LinkHead);voidRelease(LinkHead);LinkAdd(LinkHead);boolSearch(LinkHead);LinkSearch_Unique(LinkHead);voidDisplay_L
3、ist(LinkHead);voidDisplay_Node(LinkpNode);LinkModify(LinkHead);LinkDel(LinkHead);voidSave_ByFile(LinkHead,fstream&ofile);LinkSort(LinkHead);//-------函数实现--------------------------LinkCreate(LinkHead){//创建一个带头节点的空链表。Head=(Link)newNode;if(!Head){cout<<"分配内存失败!"<4、d->m_Code="";Head->m_Name="";Head->m_Year=0;Head->m_Sex="";Head->m_Post="";Head->m_Department="";Head->m_Wage=0;Head->Next=NULL;returnHead;}voidRelease(LinkHead){//释放链表。Linkptr;//声明一个操作用的指针。while(Head!=NULL){ptr=Head;Head=Head->Next;deleteptr;//释放节点资源。}}LinkAdd(LinkHead){//前插法添加数据5、。LinkpNew;//声明一个新节点。charagain;stringcode,name,sex,post,department;unsignedshortintyear;unsignedintwage;do{pNew=(Link)newNode;//数据域。cout<<"请输入职工代码:";cin>>code;cout<>name;cout<>year;while(cin.fail()){cout<<"请输入正确的年份格式。"<6、;fflush(stdin);cin>>year;}cout<>sex;cout<>post;cout<>department;cout<>wage;while(cin.fail()){cout<<"请输入正确的工资数据。"<>wage;}cout<m_Code=code;pNew->m_7、Name=name;pNew->m_Year=year;pNew->m_Sex=sex;pNew->m_Post=post;pNew->m_Department=department;pNew->m_Wage=wage;//指针域。pNew->Next=Head->Next;Head->Next=pNew;cout<<"数据添加成功!是否继续添加?(Y/N)"<>again;}while(again=='Y'8、9、again=='y');returnHead;}boolSearch(LinkHead){//查询同时满足“姓名”和“部门”的10、职工信息。Linkptr;stringdepartment;str
4、d->m_Code="";Head->m_Name="";Head->m_Year=0;Head->m_Sex="";Head->m_Post="";Head->m_Department="";Head->m_Wage=0;Head->Next=NULL;returnHead;}voidRelease(LinkHead){//释放链表。Linkptr;//声明一个操作用的指针。while(Head!=NULL){ptr=Head;Head=Head->Next;deleteptr;//释放节点资源。}}LinkAdd(LinkHead){//前插法添加数据
5、。LinkpNew;//声明一个新节点。charagain;stringcode,name,sex,post,department;unsignedshortintyear;unsignedintwage;do{pNew=(Link)newNode;//数据域。cout<<"请输入职工代码:";cin>>code;cout<>name;cout<>year;while(cin.fail()){cout<<"请输入正确的年份格式。"<6、;fflush(stdin);cin>>year;}cout<>sex;cout<>post;cout<>department;cout<>wage;while(cin.fail()){cout<<"请输入正确的工资数据。"<>wage;}cout<m_Code=code;pNew->m_7、Name=name;pNew->m_Year=year;pNew->m_Sex=sex;pNew->m_Post=post;pNew->m_Department=department;pNew->m_Wage=wage;//指针域。pNew->Next=Head->Next;Head->Next=pNew;cout<<"数据添加成功!是否继续添加?(Y/N)"<>again;}while(again=='Y'8、9、again=='y');returnHead;}boolSearch(LinkHead){//查询同时满足“姓名”和“部门”的10、职工信息。Linkptr;stringdepartment;str
6、;fflush(stdin);cin>>year;}cout<>sex;cout<>post;cout<>department;cout<>wage;while(cin.fail()){cout<<"请输入正确的工资数据。"<>wage;}cout<m_Code=code;pNew->m_
7、Name=name;pNew->m_Year=year;pNew->m_Sex=sex;pNew->m_Post=post;pNew->m_Department=department;pNew->m_Wage=wage;//指针域。pNew->Next=Head->Next;Head->Next=pNew;cout<<"数据添加成功!是否继续添加?(Y/N)"<>again;}while(again=='Y'
8、
9、again=='y');returnHead;}boolSearch(LinkHead){//查询同时满足“姓名”和“部门”的
10、职工信息。Linkptr;stringdepartment;str
此文档下载收益归作者所有