數(shù)據(jù)結(jié)構(gòu)--員工管理信息系統(tǒng)代碼(共9頁(yè))_第1頁(yè)
數(shù)據(jù)結(jié)構(gòu)--員工管理信息系統(tǒng)代碼(共9頁(yè))_第2頁(yè)
數(shù)據(jù)結(jié)構(gòu)--員工管理信息系統(tǒng)代碼(共9頁(yè))_第3頁(yè)
數(shù)據(jù)結(jié)構(gòu)--員工管理信息系統(tǒng)代碼(共9頁(yè))_第4頁(yè)
數(shù)據(jù)結(jié)構(gòu)--員工管理信息系統(tǒng)代碼(共9頁(yè))_第5頁(yè)
已閱讀5頁(yè),還剩4頁(yè)未讀, 繼續(xù)免費(fèi)閱讀

下載本文檔

版權(quán)說(shuō)明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)

文檔簡(jiǎn)介

1、精選優(yōu)質(zhì)文檔-傾情為你奉上數(shù)據(jù)結(jié)構(gòu)-員工管理信息系統(tǒng)源程序#include<iostream>#include<string>#include <stdlib.h>#include <stdio.h>using namespace std;#define OK 1#define ERROR 0#define OVERFLOW -2typedef int Status;/Status 是函數(shù)返回值類(lèi)型,其值是函數(shù)結(jié)果狀態(tài)代碼。#define MAXSIZE 100/順序表可能達(dá)到的最大長(zhǎng)度typedef struct /ElemType 為自定義的

2、數(shù)據(jù)類(lèi)型,要根據(jù)實(shí)際情況定義,本例為學(xué)生信息:(學(xué)號(hào),成績(jī))int num;string name;string sex; string birth;string edu;string job;string phone; string add;ElemType; typedef struct /定義順序表類(lèi)型為L(zhǎng)istElemType *elem;int length;List;void InitList(List &L)/創(chuàng)建空順序表L.elem=new ElemTypeMAXSIZE; /動(dòng)態(tài)分配空間L.length=0;void ListInput(List &L,int

3、 n)/輸入順序表數(shù)據(jù)int i;cout<<"請(qǐng)輸入員工信息"<<endl;for(i=0;i<n;i+)cout<<"請(qǐng)輸入員工編號(hào):"<<endl;cin>>L.elemi.num; /輸入員工編號(hào) cout<<"請(qǐng)輸入員工姓名"<<endl; cin>>L.; /輸入姓名 cout<<"請(qǐng)輸入員工性別:"<<endl;cin>>L.elemi.sex;

4、 /輸入員工編號(hào)cout<<"請(qǐng)輸入員工出生年月"<<endl;cin>>L.elemi.birth; cout<<"請(qǐng)輸入員工職務(wù)"<<endl;cin>>L.elemi.job; cout<<"請(qǐng)輸入員工學(xué)歷"<<endl;cin>>L.; cout<<"請(qǐng)輸入員工電話號(hào)碼"<<endl;cin>>L.elemi.phone; cout<<

5、"請(qǐng)輸入員工住址"<<endl;cin>>L.elemi.add; L.length=n;void ListOutput(List L)/輸出順序表數(shù)據(jù)int i=0;if (L.length=0) cout<<"空表,無(wú)數(shù)據(jù)輸出!"for(i=0;i<L.length;i+)cout<<"("<<L.elemi.num<<","<<L.<<","<<L.elem

6、i.birth<<","<<L.elemi.job<<","<<L.<<","<<L.elemi.phone<<","<< L.elemi.add<<")"<<endl;/輸出數(shù)據(jù)cout<<endl;int LocateElem(List L,int num) /在順序表里查找某編號(hào)員工的信息int i;for(i=0;i<L.length

7、;i+)if(num=L.elemi.num)return i+1;else return 0;void ListInsert(List &L,ElemType e) /順序表的插入 int i;if(L.length=MAXSIZE)cout<<"存儲(chǔ)空間已滿"/當(dāng)前存儲(chǔ)空間已滿 if(LocateElem(L,e.num)!=0)cout<<"數(shù)據(jù)已存在,請(qǐng)重新輸入"elsefor(i=L.length-1;i>=0;i-) if (e.num<L.elemi.num) L.elemi+1=L.elemi;

8、/在查找位置的同時(shí)元素后移 else break;L.elemi+1=e;/將新元素e放入合適的位置+L.length;/表長(zhǎng)增1void ListDelete(List &L,int bh) / 順序表的刪除int i,j;i=LocateElem(L,bh); /查找刪除位置 if(i=0)cout<<"找不到此員工相關(guān)信息" elsefor(j=i;j<=L.length;j+)L.elemj-1=L.elemj;/被刪除元素之后的元素前移-L.length;/表長(zhǎng)減1void BubbleSort(List &L) int i,j;

9、 ElemType key; for(i=0;i<L.length-1;i+) for(j=i+1;j<L.length;j+) if(L.elemi.num>L.elemj.num) key=L.elemi; L.elemi=L.elemj; L.elemj=key; void ChangeM(List &L)int i,n,num; cout<<"ttt* 請(qǐng)輸入更改的員工編號(hào) *"<<endl; cin>>num;cout<<"ttt*"<<endl; cout&

10、lt;<"ttt* *"<<endl; cout<<"ttt* 1 改名字 *"<<endl; cout<<"ttt* 2 改電話 *"<<endl; cout<<"ttt* 3 改性別 *"<<endl; cout<<"ttt* 4 改學(xué)歷 *"<<endl; cout<<"ttt* 5 改住址 *"<<endl; cout<<

11、;"ttt* 6 改編號(hào) *"<<endl; cout<<"ttt* 7 改工作 *"<<endl; cout<<"ttt* 8 改生日 *"<<endl; cout<<"ttt*n"cout<<"ttt* 請(qǐng)輸入1-8選擇修改項(xiàng) *"<<endl;cin>>n;for(i=0;i<L.length;i+) if(num=L.elemi.num) /查找刪除位置 break; if(

12、i<L.length) switch(n) case 1: cout<<"ttt 請(qǐng)輸入新內(nèi)容:"<<endl; cin>>L.;break; case 2: cout<<"ttt 請(qǐng)輸入新內(nèi)容:"<<endl; cin>>L.elemi.phone;break; case 3: cout<<"ttt 請(qǐng)輸入新內(nèi)容:"<<endl; cin>>L.elemi.sex;break; case 4: cou

13、t<<"ttt 請(qǐng)輸入新內(nèi)容:"<<endl; cin>>L.;break; case 5: cout<<"ttt 請(qǐng)輸入新內(nèi)容:"<<endl; cin>>L.elemi.add;break; case 6: cout<<"ttt 請(qǐng)輸入新內(nèi)容:"<<endl; cin>>L.elemi.num;break; case 7: cout<<"ttt 請(qǐng)輸入新內(nèi)容:"<<

14、;endl; cin>>L.elemi.job;break; case 8: cout<<"ttt 請(qǐng)輸入新內(nèi)容:"<<endl; cin>>L.elemi.birth;break; else cout<<"未找到要修改的員工信息,請(qǐng)檢查是否編號(hào)輸入有誤!n"void menu(void) /主菜單system("cls");cout<<"nn" cout<<"ttt 員工管理系統(tǒng)n" cout<<&

15、quot;ttt*n" cout<<"ttt* *n" cout<<"ttt* 1 數(shù) 據(jù) 輸 入 *n" cout<<"ttt* 2 查 詢(xún) 數(shù) 據(jù) *n" cout<<"ttt* 3 更 新 數(shù) 據(jù) *n" cout<<"ttt* 4 插 入 數(shù) 據(jù) *n" cout<<"ttt* 5 刪 除 數(shù) 據(jù) *n" cout<<"ttt* 6 員 工 排 序 *n"

16、 cout<<"ttt* 7txt文件(員工信息) *n" cout<<"ttt* 8 文 件 導(dǎo) 出 *n" cout<<"ttt* 9 退 出 *n" cout<<"ttt* *n" cout<<"ttt* *n" cout<<"ttt*n" cout<<"ttt 請(qǐng)輸入你的選項(xiàng)(1-8):"void newFile(List &L) int i; int nu

17、m;string name; string sex; string birth; string edu; string job; string phone; string add; FILE *fp;if(fp=fopen("f1.txt","w")=NULL)cout<<"file open error!n"exit(0); for(i=0;i<L.length;i+)num=L.elemi.num;name=L.; sex=L.elemi.sex; birth=L.elemi.birth; e

18、du=L.; job=L.elemi.job; phone=L.elemi.phone; add=L.elemi.add; fprintf(fp,"%d",num); fputs(" ",fp); fputs(const char *)(name.c_str(),fp);fputs(" ",fp); fputs(const char *)(sex.c_str(),fp); fputs(" ",fp); fputs(const char *)(birth.c_str(),fp); fputs(&qu

19、ot; ",fp); fputs(const char *)(edu.c_str(),fp); fputs(" ",fp); fputs(const char *)(job.c_str(),fp); fputs(" ",fp); fputs(const char *)(phone.c_str(),fp); fputs(" ",fp); fputs(const char *)(add.c_str(),fp); fputs(" ",fp);fputs("n",fp); fclose(fp)

20、; void readFile(List &L) FILE *fp;if(fp=fopen("f1.txt","r")=NULL)cout<<"file open error!n"exit(0);while(!feof(fp)char a;a=fgetc(fp);putchar(a); void main()List L;int i,n,m;char name;ElemType e;InitList(L);while(1) menu();cin>>i; switch(i) case 1: cout<

21、;<"請(qǐng)輸入員工總?cè)藬?shù):"cin>>n;ListInput(L,n); ListOutput(L); break; case 2:cout<<"請(qǐng)輸入要查找的員工編號(hào):" cin>>n; m=LocateElem(L,n);if (m=0) cout<<"數(shù)據(jù)不存在"else cout<<"該員工的信息為:" cout<<L.elemm-1.num<<","<<L.<

22、;<","<<L.elemm-1.sex<<","<<L.elemm-1.birth<<","<<L.elemm-1.job<<","<<L.<<","<<L.elemm-1.phone<<","<<L.elemm-1.add<<" " break;case 3: ChangeM(L); ListOutput(L); break; case 4: cout<<"請(qǐng)輸入要插入的數(shù)據(jù),"<<e

溫馨提示

  • 1. 本站所有資源如無(wú)特殊說(shuō)明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒(méi)有圖紙預(yù)覽就沒(méi)有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫(kù)網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。

評(píng)論

0/150

提交評(píng)論