![職工信息管理系統(tǒng)源代碼_第1頁](http://file3.renrendoc.com/fileroot_temp3/2022-2/28/aa73d093-30cc-4fc2-9446-7c0bded4f52a/aa73d093-30cc-4fc2-9446-7c0bded4f52a1.gif)
![職工信息管理系統(tǒng)源代碼_第2頁](http://file3.renrendoc.com/fileroot_temp3/2022-2/28/aa73d093-30cc-4fc2-9446-7c0bded4f52a/aa73d093-30cc-4fc2-9446-7c0bded4f52a2.gif)
![職工信息管理系統(tǒng)源代碼_第3頁](http://file3.renrendoc.com/fileroot_temp3/2022-2/28/aa73d093-30cc-4fc2-9446-7c0bded4f52a/aa73d093-30cc-4fc2-9446-7c0bded4f52a3.gif)
版權說明:本文檔由用戶提供并上傳,收益歸屬內容提供方,若內容存在侵權,請進行舉報或認領
文檔簡介
1、h># i n c l u d e < s t d i #include<string.h>#include<stdlib.h> int N=2;struct worker /* 定義一個職工信息的結構體 */定義一個職工信息的結構體 */定義一個職工信息的結構體 */ 用字符串存放職工的性別數(shù)據(jù)用字符串存放職工的出生年月數(shù)據(jù)用字符串存放職工的工作年月數(shù)據(jù) 用字符串存放職工的學歷數(shù)據(jù) 用字符串存放職工的性別數(shù)據(jù) 用字符串存放職工的職務數(shù)據(jù) 用字符串存放職工的地址數(shù)據(jù) 用字符串存放職工的電話數(shù)據(jù) 用結構體數(shù)組存放職工的所有信息int num; /*char n
2、ame20; /*char sex10;/char birth20;/char deta20; / char education20; / double salary;/char work30;/char addr20; / char tel20; / worker100; / void menu(); void input(); void save(); void read(); void display();void add();void search();void search_education();void search_num();void del();void modify();
3、void main()char s; system("color 3f"); printf("nn");printf(" t n");printf("n");printf(" tn");printf("n");printf(" tn");printf(" t n");printf(" ttt*歡迎使用職工信息管理系統(tǒng)*'k'k'kI * *n");printf(" t n"
4、);printf(" tn");printf(" tn");printf(" t n");printf(" t*| *制作人吳青伶*'k'k'k*'k'k'k| *'k'k'kI * *n");printf("n");printf(" tn");printf("n");printf(" tn");dot*t*menu();printf("Do you wa
5、nt to continue?(y/n)"); s=getchar();while(s='Y'|s='y');void menu()/* 菜單函數(shù) */int b;printf("tn");printf("tn");printf("tn");printf("tn");printf("tn");printf("t請選擇n");printf("t n");printf("t| n");printf(
6、"t|1.職工信息錄入|n");printf("t|2.職工信息瀏覽|n");printf("t|3.職工信息添加|n");printf("t|4.職工信息查詢|n");printf("t|5.職工信息刪除|n");printf("t|6.職工信息修改|n");printf("t|0.退出| n");printf("t n");printf("n 輸入你的選擇項 (06):n"); scanf("%d&qu
7、ot;,&b);switch(b)case 1 : /職工信息錄入、保存input();save();getchar();break;case 2 :/讀入職工信息并顯示read();display();getchar();break;case 3 : /添加職工信息add();getchar();break;case 4 : /查詢職工信息search();getchar();break;case 5 : /讀入職工信息并實現(xiàn)職工信息刪除功能read();del();getchar();break;case 6 : /讀入職工信息并修改職工信息read();modify();getc
8、har();break;case 0 : exit(0);/退出default:break;void input() / 錄入職工信息int i,flag,j;printf(" 輸入職工個數(shù) ( 默認個數(shù)為 2) : ");scanf("%d",&N);fflush(stdin);/ 清除緩存for(i=0;i<N;i+)loop:printf("職工號 :");scanf("%d",&workeri.num); fflush(stdin);flag=1;if(workerN.num<0
9、)printf(" 請輸入正整數(shù): n");elsefor(j=0;j<i;j+)if(workeri.num=workerj.num)flag=0;printf(" 工號重復,請重新輸入 !n"); goto loop;printf("姓名 :");scanf("%s",); fflush(stdin);printf("性別 :");scanf(" %s",workeri.sex); fflush(stdin);printf("出生年
10、月 :");scanf("%d",&workeri.birth); fflush(stdin);printf("工作年月 :");scanf("%lf",&workeri.deta); fflush(stdin);printf(”請輸入學歷(中專=zz,大專=dz,本科=bk,研究生=yjs):n");scanf("%s",cation);fflush(stdin);printf("工資 :");scanf("%lf"
11、,workeri.salary); fflush(stdin);printf("職務 :");scanf("%s",workeri.work); fflush(stdin);printf("住址 :");scanf("%s",workeri.addr); fflush(stdin);printf("電話 :");scanf("%s",workeri.tel); fflush(stdin);printf("n 創(chuàng)建完畢 !n"); void save() /
12、 保存函數(shù)FILE *fp;int i;if(fp=fopen("worker.txt","wb")=NULL)/printf("ncannot open filen"); exit(0);for(i=0;i<N;i+)fwrite(&workeri,sizeof(struct worker),1,fp);/ 到磁盤文件中去(二進制)fclose(fp); void read() / 讀入函數(shù)FILE *fp;int i=0;if(fp=fopen("worker.txt","rb"
13、;)=NULL) / 個二進制文件以只寫方式打開一個二進制文件將內存中的職工信息數(shù)據(jù)輸出以只讀方式為輸出打開磁盤文件中的一printf("ncannot open filen");exit(0);dofread(&workeri,sizeof(struct 數(shù)據(jù)(二進制)i+;while(!feof(fp);fclose(fp);N=i-1;worker),1,fp);/ 從 worker.txt文件向內存讀入void display() / int i;信息瀏覽函數(shù)for(i=0;i<N;i+)printf("職工號 :%dn",work
14、eri.num);printf("姓名 :%sn",);printf("性別 :%sn",workeri.sex);printf("出生年月 :%dn",workeri.birth);printf("工作年月 :%dn",workeri.deta);printf("學歷 :%sn",cation);printf("工資 :%lfn",workeri.salary);printf("職務 :%dn",worker
15、i.work);printf("住址 :%sn",workeri.addr);printf("電話 :%sn",workeri.tel);void add() / 添加函數(shù)FILE *fp;int i;struct worker p; double t;printf("n 請輸入新增加職工的信息 :n"); printf(" 請輸入職工號 :n");scanf("%d",&p.num);for(i=0;i<N;i+) while(workeri.num=p.num)printf(&
16、quot; 工號重復,請重新輸入 !n"); scanf("%d",&p.num);printf(" 請輸入姓名 :n");scanf("%s",);printf("請輸入性別 :n");scanf("%s",p.sex);printf("請輸入出生年月 :n");scanf("%d",&p.birth);printf(" 請輸入工作年月 :n");scanf("%d",&
17、;p.deta);printf(" 請 輸 入 學 歷 ( 中 專 =zz , 大 專 =dz , 本 科 =bk , 研 究 生 =yjs : ):n");scanf("%s",cation);printf(" 請輸入工資 :n");scanf("%lf",&t);p.salary=t;printf(" 請輸入職務 :n");scanf("%s",p.work);printf("請輸入住址 :n");scanf("%s&quo
18、t;,p.addr);printf("請輸入電話 :n");scanf("%s",p.tel);printf("n 添加完畢 !n"); if(fp=fopen("worker.txt","ab")=NULL)/ 以追加方式打開一個二進制文件尾部printf("ncannot open filen");exit(0); fwrite(&p,sizeof(struct worker),1,fp);fclose(fp); void search() / 查詢函數(shù)int c
19、;do puts("nsearch by=>n1.學歷 2. 職工號 3. 取消并返回 ");printf("Which you needed?:n"); scanf("%d",&c);if(c>3|c<1) puts("nchoice error!please again!");getchar();/ 此語句用于接受在執(zhí)行上一句時最后輸出的回車符 while(c>3|c<1);switch(c)case 1:search_education();break;case 2:se
20、arch_num();break;case 3:menu();break;void search_education() / 按學歷查詢函數(shù)int i,flag=0;char s10;printf("n 請輸入你要查詢的學歷 :n");scanf("%s",s);for(i=0;i<N;i+) if(strcmp(s,cation)=0)printf("職工號 :%dn",workeri.num);printf("姓名 :%sn",);printf("性
21、別 :%sn",workeri.sex);printf("出生年月 :%dn",workeri.birth);printf("工作年月 :%dn",workeri.deta);printf(”學歷(中專=zz , 大專=dz , 本科 =bk ,研究生=yjs):%sn",cation);printf("工資 :%lfn",workeri.salary);printf("職務 :%lfn",workeri.work);printf("住址 :%sn",w
22、orkeri.addr);printf("電話 :%sn",workeri.tel);flag+;if(flag=0)printf("n對不起沒有找到 !n");getchar();void search_num() /按工號查詢函數(shù)int i,s,flag=0;printf("n輸入要查詢的職工號 !:n");scanf("%d",&s);for(i=0;i<N;i+)if(s=workeri.num)printf("職工號 :%dn",workeri.num);printf(&
23、quot;姓名 :%sn",);printf("性別 :%sn",workeri.sex);printf("出生年月 :%dn",workeri.birth);printf("工作年月 :%dn",workeri.deta);printf(" 學 歷 ( 中 專 =zz , 大 專 = dz , 本 科 = bk , 研 究 生 = yjs):%sn",cation);printf("工資 :%lfn",workeri.salary);pr
24、intf("職務 :%lfn",workeri.work);printf("住址 :%sn",workeri.addr);printf("電話 :%sn",workeri.tel);flag+;if(flag=0)printf("n對不起沒有找到 ! please");getchar(); void del() / 刪除函數(shù)int i,j;FILE *fp;char name20;char c;if(fp=fopen("worker.txt","wb")=NULL)/ 以只寫
25、方式打開一個二進制文件 printf("ncannot open filen"); exit(0);printf(" 請輸入要刪除的職工的姓名 :"); scanf("%s",name);for(i=0;i<N;i+)if(strcmp(name,)=0)/ 判斷輸入的姓名和原來的姓名是否相同 printf(" 找到該職工 ,是否刪除 ?(y/n) ") ; fflush(stdin);scanf("%c",&c);if(c ='Y'|c=&
26、#39;y') for(j=i;j<N;j+) workerj=workerj+1; printf(" 刪除成功 ! n"); /break;if(i>=N)printf(" 沒有找到該職工 !n "); return;elseN=N-1; for(i=0;i<N;i+) if(fwrite(&workeri,sizeof(struct worker),1,fp)!=1) printf("ncannot save filen"); getchar();fclose(fp); void modify()
27、 / 修改函數(shù)struct worker p;FILE *fp;int i,n; double t; printf("n 輸入要修改的職工號 :n"); scanf("%d",&n);for(i=0;i<N;i+) if(n=workeri.num)printf("找到該職工的信息 ( 任意鍵繼續(xù) ) !");printf("n 請輸入職工的信息! n");printf("請輸入姓名 :n");scanf("%s",);printf("請輸入性別 :n");scanf("%s&quo
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
- 4. 未經(jīng)權益所有人同意不得將文件中的內容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內容本身不做任何修改或編輯,并不能對任何下載內容負責。
- 6. 下載文件中如有侵權或不適當內容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 文學社組社方案及招生簡章范文
- 現(xiàn)代企業(yè)財務管理的全球化視角
- 全鋼爬架施工方案
- 汽車行業(yè)的品牌競爭戰(zhàn)略分析
- 國慶節(jié)小吃店鋪活動方案
- 國慶節(jié)手工干貨活動方案
- 12《富起來到強起來》第一課時說課稿-2023-2024學年道德與法治五年級下冊統(tǒng)編版001
- 2023六年級英語上冊 Unit 3 Winter in canada Lesson 14 Snow!It's Winter說課稿 冀教版(三起)
- 2024-2025學年新教材高中物理 第三章 恒定電流 第3節(jié) 測量金屬絲的電阻率說課稿 粵教版必修3
- 2024秋七年級數(shù)學上冊 第3章 一次方程與方程組3.4 二元一次方程組的應用 2列二元一次方程組解實際應用(一)說課稿(新版)滬科版
- 2025-2030年中國電動高爾夫球車市場運行狀況及未來發(fā)展趨勢分析報告
- 河南省濮陽市2024-2025學年高一上學期1月期末考試語文試題(含答案)
- 2024年湖南高速鐵路職業(yè)技術學院單招職業(yè)適應性測試題庫及答案解析
- 安全事故案例圖片(76張)課件
- 預應力錨索施工方案
- 豇豆生產(chǎn)技術規(guī)程
- 奢侈品管理概論完整版教學課件全書電子講義(最新)
- 文藝美學課件
- 中藥炮制學教材
- 常見腫瘤AJCC分期手冊第八版(中文版)
- 電氣第一種第二種工作票講解pptx課件
評論
0/150
提交評論