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

下載本文檔

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

文檔簡(jiǎn)介

1、數(shù)據(jù)結(jié)構(gòu) -員工管理信息系統(tǒng)源程序 #include #include #include #include using namespace std; #define OK 1 #define ERROR 0 #define OVERFLOW -2 typedef int Status;/Status 是函數(shù)返回值類(lèi)型,其值是函數(shù)結(jié)果狀態(tài)代碼。 #define MAXSIZE 100/順序表可能達(dá)到的最大長(zhǎng)度 typedef struct /ElemType 為自定義的數(shù)據(jù)類(lèi)型,要根據(jù)實(shí)際情況定義,本 例為學(xué)生信息 :(學(xué)號(hào) ,成績(jī)) int num; string name; string s

2、ex; string birth; string edu; string job; string phone; string add; ElemType; typedef struct / 定義順序表類(lèi)型為 List ElemType *elem; int length; List; void InitList(List 動(dòng)態(tài)分配空間 L.length=0; void List In put(List coutvv請(qǐng)輸入員工信息endl; for(i=0;in;i+) coutvv請(qǐng)輸入員工編號(hào):L.elemi. num;/ 輸入員工編號(hào) coutvv請(qǐng)輸入員工姓名 L.elemi. name

3、;/ 輸入姓名 coutvv請(qǐng)輸入員工性別:L.elemi.sex; 輸入員工編號(hào) coutvv請(qǐng)輸入員工出生年月vvendl; cinL.elemi.birth; coutvv請(qǐng)輸入員工職務(wù)L.elemi.job; coutvv請(qǐng)輸入員工學(xué)歷L.; coutvv請(qǐng)輸入員工電話(huà)號(hào)碼vvendl; cinL.elemi.phone; coutvv請(qǐng)輸入員工住址vvendl; cinL.elemi.add; L.length=n; void ListOutput(List L) 輸出順序表數(shù)據(jù) int i=0; if (L.le ngth=O) coutvv空表,無(wú)數(shù)據(jù)輸出!;

4、for(i=0;ivL.length;i+) coutvv(vvL.elemi.numvv,vvL.vv,vvL.elemi.birthvv,vvL.e lemi.jobvv,vvL.vv,vvL.elemi.phonevv,vv L.elemi.addvv)vvendl; 輸出數(shù)據(jù) coutvvendl; int LocateElem(List L,i nt num)/在順序表里查找某編號(hào)員工的信息 int i; for(i=0;iL.length;i+) if(num=L.elemi.num) return i+1; else return 0; vo

5、id Listl nsert(List if(L.length=MAXSIZE)coutv=0;i-) if (e.numL.elemi.num) L.elemi+1=L.elemi; else break; L.elemi+1=e; +L.length; void ListDelete(List i=LocateElem(L,bh); if(i=0) coutvv找不到此員工相關(guān)信息 else for(j=i;j=L.length;j+) L.elemj-1=L.elemj; -L.length; void BubbleSort(List ElemType key; for(i=0;iL.l

6、ength-1;i+) for(j=i+1;jL.elemj.num) key=L.elemi; L.elemi=L.elemj; L.elemj=key;/ 在查找位置的同時(shí)元素后移 / 將新元素 e 放入合適的位置 / 表長(zhǎng)增 1 / 順序表的刪除 / 查找刪除位置 / 被刪除元素之后的元素前移 / 表長(zhǎng)減 1 void ChangeM(List coutttt* 請(qǐng)輸入更改的員工編號(hào) *num; endl; coutttt* coutttt*endl; 18 / 16 coutttt* 1 coutttt* 2 coutttt* 3 coutttt* 4 coutttt* 5 coutt

7、tt* 6 改名字 *endl; 改電話(huà) *endl; 改性別 *endl; 改學(xué)歷 *endl; 改住址 *endl; 改編號(hào) *endl; coutttt* 7 改工作 *endl; coutttt* 8 改生日 *endl; coutttt* * n; coutttt* 請(qǐng)輸入 1-8 選擇修改項(xiàng) *n; for(i=0;iL.length;i+) if(num=L.elemi.num)/ 查找刪除位置 break; if(iL.length) switch(n) case 1: coutttt 請(qǐng)輸入新內(nèi)容: L.;break; case 2: coutttt 請(qǐng)輸

8、入新內(nèi)容: L.elemi.phone;break; case 3: coutttt 請(qǐng)輸入新內(nèi)容: L.elemi.sex;break; case 4: coutttt 請(qǐng)輸入新內(nèi)容: L.;break; case 5: coutttt 請(qǐng)輸入新內(nèi)容: L.elemi.add;break; case 6: coutttt 請(qǐng)輸入新內(nèi)容: L.elemi.num;break; case 7: coutttt 請(qǐng)輸入新內(nèi)容: L.elemi.job;break; case 8: coutttt 請(qǐng)輸入新內(nèi)容: L.elemi.birth;break; else !n; cout

9、vv未找到要修改的員工信息,請(qǐng)檢查是否編號(hào)輸入有誤 void menu(void)/ 主菜單 system(cls); coutnn; coutttt 員工管理系統(tǒng) n; coutttt* * n; coutttt*n; coutttt* 1 數(shù)據(jù)輸入 *n; coutttt* 2 查詢(xún)數(shù)據(jù) *n; coutttt* 3 更新數(shù)據(jù) *n; coutttt* 4 插入數(shù)據(jù) *n; coutttt* 5 刪除數(shù)據(jù) *n; coutttt* 6 員工排序 *n; coutttt* 7txt 文件(員工信息 )*n; coutttt* 8 文件導(dǎo)出 *n; coutttt* 9 退出 *n; cout

10、ttt*n; coutttt*n; coutttt* * n; coutttt 請(qǐng)輸入你的選項(xiàng) (1-8):; void newFile(List int num; string name; string sex; string birth; string edu; string job; string phone; string add; FILE *fp; if(fp=fopen(f1.txt,w)=NULL) coutfile open error!n; exit(0); for(i=0;iL.length;i+) num=L.elemi.num; name=L.;

11、sex=L.elemi.sex; birth=L.elemi.birth; edu=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( ,fp); fput

12、s(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); void readFile(List if(fp=fopen(f1.txt,r)=NULL) couti; switch(i) case 1: coutv

13、v請(qǐng)輸入員工總?cè)藬?shù):; cinn; ListInput(L,n); ListOutput(L); break; case 2: coutvv請(qǐng)輸入要查找的員工編號(hào): cinn; m=LocateElem(L,n); if (m=0) coutvv數(shù)據(jù)不存在; else coutvv該員工的信息為:; coutL.elemm-1.num,L.,L.elemm- 1.sex,L.elemm-1.birth,L.elemm-1.job,L.elemm- 1.edu,L.elemm-1.phone,L.elemm-1.add ; break; case 3: ChangeM(L); ListOutput(L); break; case 4: coutvv請(qǐng)輸入要插入的數(shù)據(jù),e.num; ; cine.sex; cine.birth; cine.job; ; cine.phone; cine.add; ListInsert(L,e); ListOutput(L); break; case 5: coutvv請(qǐng)輸入要?jiǎng)h除學(xué)號(hào)的員工編號(hào): cinn; ListDelete(L,n); ListOutput(L); break;

溫馨提示

  • 1. 本站所有資源如無(wú)特殊說(shuō)明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶(hù)所有。
  • 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ì)用戶(hù)上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶(hù)上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶(hù)因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。

評(píng)論

0/150

提交評(píng)論