




版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(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<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ù)返回值類型,其值是函數(shù)結(jié)果狀態(tài)代碼。#define MAXSIZE 100/順序表可能達(dá)到的最大長(zhǎng)度typedef struct /ElemType 為自定義的數(shù)據(jù)類型,要根據(jù)實(shí)際情況定
2、義,本例為學(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(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 n)/輸入順序表數(shù)據(jù)in
3、t 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; /輸入員工編號(hào)cout&
4、lt;<"請(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<<"請(qǐng)輸入員工住址
5、"<<endl;cin>>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;i<L.length;i+)cout<<"("<<L.elemi.num<<","<<L.<<","<<L.elemi.birth<&l
6、t;","<<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;i+)if(num=L.
7、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;/在查找位置的同時(shí)元素后移
8、 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; ElemType key
9、; 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、ttt* *"<<endl; cout<<"ttt* 1 改名字 *"<<endl; cout<<"ttt* 2 改電話 *"<<endl; cout<<"ttt* 3 改性別 *"<<endl; cout<<"ttt* 4 改學(xué)歷 *"<<endl; cout<<"ttt* 5 改住址 *"<<endl; cout<<"ttt* 6
11、 改編號(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(i<L.length
12、) 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: cout<<&quo
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)容:"<<endl; cin>
14、;>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<<"ttt*n&qu
15、ot; cout<<"ttt* *n" cout<<"ttt* 1 數(shù) 據(jù) 輸 入 *n" cout<<"ttt* 2 查 詢 數(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" cout<<
16、"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 num;string name
17、; 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; edu=L.elemi.ed
18、u; 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
19、); 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 readFi
20、le(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<<"請(qǐng)輸
21、入員工總?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、quot;<<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ù),"<
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 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ì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 【正版授權(quán)】 IEC TS 63165:2024 EN Requirements for industrial water quality analyzer system – Photometry
- 2025年浙江省安全員-C證考試(專職安全員)題庫(kù)及答案
- 2025-2030年中國(guó)鋼材加工配送中心行業(yè)運(yùn)行態(tài)勢(shì)及發(fā)展規(guī)劃分析報(bào)告
- 2025-2030年中國(guó)金融信息化行業(yè)運(yùn)營(yíng)狀況及發(fā)展前景分析報(bào)告
- 2025-2030年中國(guó)酒石酸美托洛爾緩釋片行業(yè)運(yùn)行動(dòng)態(tài)與十三五規(guī)劃研究報(bào)告
- 2025-2030年中國(guó)螺旋泵市場(chǎng)運(yùn)營(yíng)狀況及發(fā)展前景分析報(bào)告
- 2025-2030年中國(guó)薯?xiàng)l行業(yè)運(yùn)行狀況與前景趨勢(shì)分析報(bào)告
- 西雙版納職業(yè)技術(shù)學(xué)院《集裝箱與國(guó)際物流運(yùn)輸管理》2023-2024學(xué)年第二學(xué)期期末試卷
- 河北師范大學(xué)《節(jié)目策劃》2023-2024學(xué)年第二學(xué)期期末試卷
- 西京學(xué)院《商務(wù)應(yīng)用文寫作》2023-2024學(xué)年第二學(xué)期期末試卷
- 張岱年:《中國(guó)文化概論》
- 繪本成語故事:四面楚歌
- HCIE-Transmission H12-931認(rèn)證培訓(xùn)考試題庫(kù)匯總(含答案)
- 造血細(xì)胞與基本檢驗(yàn)方法-細(xì)胞化學(xué)染色(血液學(xué)檢驗(yàn)課件)
- 領(lǐng)子的分類詳解課件
- 產(chǎn)品質(zhì)量保證書
- 工廠員工消防安全培訓(xùn)內(nèi)容
- 調(diào)節(jié)與集合的相關(guān)性 相對(duì)調(diào)節(jié)和相對(duì)集合的關(guān)系
- 《金融工程》課程教案
- 水輪機(jī)結(jié)構(gòu)總體介紹
- 十八項(xiàng)護(hù)理核心制度培訓(xùn)課件
評(píng)論
0/150
提交評(píng)論