版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡介
1、數(shù)據(jù)結(jié)構(gòu)-員工管理信息系統(tǒng)源程序#include#include#include #include using namespace std;#define OK 1#define ERROR 0#define OVERFLOW -2typedef int Status;/Status 是函數(shù)返回值類型,其值是函數(shù)結(jié)果狀態(tài)代碼。#define MAXSIZE 100/順序表可能達(dá)到的最大長度typedef struct /ElemType 為自定義的數(shù)據(jù)類型,要根據(jù)實(shí)際情況定義,本例為學(xué)生信息:(學(xué)號(hào),成績)int num;string name;string sex; string birth
2、;string edu;string job;string phone; string add;ElemType; typedef struct /定義順序表類型為ListElemType *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 n)/輸入順序表數(shù)據(jù)int i;cout請輸入員工信息endl;for(i=0;in;i+)cout請輸入員工編號(hào):L.elemi.num; /輸入員工編號(hào) co
3、ut請輸入員工姓名L.; /輸入姓名 cout請輸入員工性別:L.elemi.sex; /輸入員工編號(hào)cout請輸入員工出生年月L.elemi.birth; cout請輸入員工職務(wù)L.elemi.job; cout請輸入員工學(xué)歷L.; cout請輸入員工電話號(hào)碼L.elemi.phone; cout請輸入員工住址L.elemi.add; L.length=n;void ListOutput(List L)/輸出順序表數(shù)據(jù)int i=0;if (L.length=0) cout空表,無數(shù)據(jù)輸出!;for(i=0;iL.length;i+)cout(L.ele
4、mi.num,L.,L.elemi.birth,L.elemi.job,L.,L.elemi.phone, L.elemi.add)endl;/輸出數(shù)據(jù)coutendl;int LocateElem(List L,int num) /在順序表里查找某編號(hào)員工的信息int i;for(i=0;iL.length;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ǔ)空間
5、已滿;/當(dāng)前存儲(chǔ)空間已滿 if(LocateElem(L,e.num)!=0)cout=0;i-) if (e.numL.elemi.num) L.elemi+1=L.elemi;/在查找位置的同時(shí)元素后移 else break;L.elemi+1=e;/將新元素e放入合適的位置+L.length;/表長增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;/被
6、刪除元素之后的元素前移-L.length;/表長減1void BubbleSort(List &L) int i,j; ElemType key; for(i=0;iL.length-1;i+) for(j=i+1;jL.elemj.num) key=L.elemi; L.elemi=L.elemj; L.elemj=key; void ChangeM(List &L)int i,n,num; coutttt* 請輸入更改的員工編號(hào) *num;coutttt*endl; coutttt* *endl; coutttt* 1 改名字 *endl; coutttt* 2 改電話 *endl; co
7、utttt* 3 改性別 *endl; coutttt* 4 改學(xué)歷 *endl; coutttt* 5 改住址 *endl; coutttt* 6 改編號(hào) *endl; coutttt* 7 改工作 *endl; coutttt* 8 改生日 *endl; coutttt*n;coutttt* 請輸入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 請輸入新內(nèi)容:L.;break; case 2: cout
8、ttt 請輸入新內(nèi)容:L.elemi.phone;break; case 3: coutttt 請輸入新內(nèi)容:L.elemi.sex;break; case 4: coutttt 請輸入新內(nèi)容:L.;break; case 5: coutttt 請輸入新內(nèi)容:L.elemi.add;break; case 6: coutttt 請輸入新內(nèi)容:L.elemi.num;break; case 7: coutttt 請輸入新內(nèi)容:L.elemi.job;break; case 8: coutttt 請輸入新內(nèi)容:L.elemi.birth;break; else cout未找到要修
9、改的員工信息,請檢查是否編號(hào)輸入有誤!n;void menu(void) /主菜單system(cls);coutnn; coutttt 員工管理系統(tǒng)n; coutttt*n; coutttt* *n; coutttt* 1 數(shù) 據(jù) 輸 入 *n; coutttt* 2 查 詢 數(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
10、退 出 *n; coutttt* *n; coutttt* *n; coutttt*n; coutttt 請輸入你的選項(xiàng)(1-8):;void newFile(List &L) int i; 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;nam
11、e=L.; 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); fp
12、uts( ,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); void readFile(List &L) FILE *fp;if(fp=fopen(f1.txt,r)=NULL)cout
13、i; switch(i) case 1: coutn;ListInput(L,n); ListOutput(L); break; case 2:coutn; m=LocateElem(L,n);if (m=0) cout數(shù)據(jù)不存在;else cout該員工的信息為:; coutL.elemm-1.num,L.,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請輸入要插入的數(shù)據(jù),endl; cout按以下順序輸入信息:編號(hào)、姓名、性別、出生年月、職務(wù)、學(xué)歷、電話號(hào)碼、地址。e.num; ; cine.sex; cine.birth; cine.job; ; cine.phone; cine.add; ListInsert(L,e); ListOutput(L); break; case 5: coutn; ListDelete(L,n); ListOutput(L);
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲(chǔ)空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 書的誕生+2古法手工造紙術(shù)+課件2025-2026學(xué)年遼海版初中美術(shù)七年級(jí)下冊
- 電機(jī)與電氣控制技術(shù) 課件 項(xiàng)目7 交流電動(dòng)機(jī)變頻調(diào)速控制電路的安裝與調(diào)試
- 《GBT 16453.5-2008 水土保持綜合治理 技術(shù)規(guī)范 風(fēng)沙治理技術(shù)》專題研究報(bào)告
- 《GBT 15721.5-2008假肢和矯形器 肢體缺失 第5部分:截肢者的臨床癥狀描述》專題研究報(bào)告
- 《GBT 1770-2008涂膜、膩?zhàn)幽ご蚰バ詼y定法》專題研究報(bào)告
- 道路安全交通課件
- 道路交通安全治理培訓(xùn)課件
- 道具制作培訓(xùn)游戲課件
- 返校安全培訓(xùn)心得體會(huì)
- 手術(shù)室層流維保質(zhì)量考核方案
- 2026國家電投招聘試題及答案
- 2024年人教版七7年級(jí)下冊數(shù)學(xué)期末質(zhì)量檢測題(附答案)
- 2025 AHA 心肺復(fù)蘇與心血管急救指南 - 第6部分:兒童基本生命支持解讀
- 2026年大慶醫(yī)學(xué)高等??茖W(xué)校單招職業(yè)技能測試模擬測試卷附答案
- 中央財(cái)經(jīng)大學(xué)金融學(xué)院行政崗招聘1人(非事業(yè)編制)參考筆試題庫及答案解析
- 【8物(HY)期末】六安市舒城縣2024-2025學(xué)年八年級(jí)上學(xué)期期末考試物理試卷
- 澆鑄工安全生產(chǎn)責(zé)任制
- 錢大媽加盟合同協(xié)議
- GB/T 20727-2006封閉管道中流體流量的測量熱式質(zhì)量流量計(jì)
- GB/T 16770.1-2008整體硬質(zhì)合金直柄立銑刀第1部分:型式與尺寸
- 初中音樂《十送紅軍》課件
評論
0/150
提交評論