數(shù)據(jù)結(jié)構(gòu)c語(yǔ)言員工信息管理系統(tǒng)_第1頁(yè)
數(shù)據(jù)結(jié)構(gòu)c語(yǔ)言員工信息管理系統(tǒng)_第2頁(yè)
數(shù)據(jù)結(jié)構(gòu)c語(yǔ)言員工信息管理系統(tǒng)_第3頁(yè)
數(shù)據(jù)結(jié)構(gòu)c語(yǔ)言員工信息管理系統(tǒng)_第4頁(yè)
數(shù)據(jù)結(jié)構(gòu)c語(yǔ)言員工信息管理系統(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、有志者自有千方百計(jì),無(wú)志者只感千難萬(wàn)難。數(shù)據(jù)結(jié)構(gòu)實(shí)習(xí)報(bào)告 -信息管理 學(xué)校 石家莊鐵道大學(xué) 指導(dǎo)老師 張翠肖 班級(jí) 信0901-1班 學(xué)號(hào) 20082406 姓名 張潔 院系 信息分院 學(xué)生信息管理系統(tǒng)一、 需求分析本程序主要是執(zhí)行鏈表的刪除插入等功能根據(jù)程序提示我們可以添加、修改、刪除員工信息并能進(jìn)行多種方式的查詢(xún)還有員工信息一覽二、 概要設(shè)計(jì)1) 為了實(shí)現(xiàn)上述功能需要定義一下抽象的數(shù)據(jù)類(lèi)型:ADT List數(shù)據(jù)對(duì)象:D=ai|aiElemSeti=12···········

2、3;··nn>=0數(shù)據(jù)關(guān)系:R1=<ai-1ai>|ai-1aiDi=12n基本操作:Init List(&L);操作結(jié)果:構(gòu)造一個(gè)空的線性表LDestroyList(&L);初始條件:線性表L存在操作結(jié)果:銷(xiāo)毀線性表LLocateElem(LI&e);初始條件:線性表L存在1<i<Listlength(L)操作結(jié)果:用e返回線性表L中第i個(gè)數(shù)據(jù)元素的值ClearList(&L);初始條件:線性表L存在操作結(jié)果:將線性表L重置為空表ADT Graph2) 本程序是由幾個(gè)函數(shù)構(gòu)成的: 主函數(shù):main() 菜單函數(shù)

3、menu(); 文件讀入函數(shù):read data(); 文件寫(xiě)入函數(shù):write data(); 信息查詢(xún)函數(shù):chaxun(); 信息更新函數(shù):gengxin(); 信息一覽函數(shù):liebiao(); 數(shù)據(jù)刪除函數(shù):shanchu(); 數(shù)據(jù)添加函數(shù):tianjia(); 數(shù)據(jù)修改函數(shù):xiugai();它們的調(diào)用關(guān)系如三、 詳細(xì)設(shè)計(jì)#include <stdio.h>#include <malloc.h>#include <stdlib.h>#include <windows.h> /清屏函數(shù)頭文件#include <string.h&

4、gt;#include <time.h>#include <io.h>#define LEN sizeof(struct emp)#define DATA "employee.txt"struct emplong int num; /編號(hào)char name20; /姓名int age; /年齡char sex4; /性別char birthday10; /生日char tel15;/電話char edu8; /學(xué)歷char pos20; /職務(wù)char add30; /住址struct emp *next;struct emp *head=NULL;

5、int t=0;void menu();void gengxin();void tianjia();void insert(struct emp *em);void display(struct emp *p);void liebiao();void chaxun();void bianhao();void shengri();void xingming();void readDate();void writeDate();void freeAll();void shanchu();void change();void devise(struct emp *p);void main()stru

6、ct emp *head=NULL;head=(struct emp *)malloc(LEN);head->next=NULL;system("color 1f");system("mode con: cols=150 lines=500");readDate();menu();system("cls");printf("nnnnnnnnnnnnnnnnnnn");printf(" 謝謝使用再見(jiàn)n");void menu(void)char ilj100;int flog;time_t

7、T;struct tm * timenow;time ( &T );timenow = localtime ( &T );flog=0;while(1)system("cls");printf("nnnnn");printf(" 員工信息管理系統(tǒng)n");printf(" n");printf(" n");printf(" n");printf(" 1.員工信息查詢(xún) n");printf(" n");printf(&quo

8、t; n");printf(" n");printf(" 2.員工信息更新 n");printf(" n");printf(" n");printf(" n");printf(" 3.員工信息列表 n");printf(" n");printf(" n");printf(" n");printf(" 0.退出管理系統(tǒng) n");printf(" n");printf(&

9、quot; n");printf(" n");printf(" n");printf(" %s" asctime (timenow) );printf("請(qǐng)輸入您的選擇(數(shù)字0-3):n");scanf("%c"&i);gets(lj);if(lj0)i='a'switch(i)case '1':chaxun();break;case '2':gengxin();break;case '3':liebiao();b

10、reak;case '0':flog=1;break;default:printf("輸入有誤請(qǐng)按回車(chē)鍵重新輸入n");gets(lj);break;if(flog)break;void tianjia()struct emp *p*p1;char lj100;p=NULL;p1=head;printf("請(qǐng)輸入第%d個(gè)員工的信息.n"t+1);p=(struct emp *)malloc(LEN);if(p=NULL)printf("分配空間失敗");exit(0);printf("請(qǐng)輸入員工的編號(hào):n&q

11、uot;);scanf("%ld"&p->num);while(p1!=NULL)&&(p->num!=p1->num)p1=p1->next;if(p1!=NULL)if(p->num=p1->num)printf("編號(hào)已經(jīng)存在請(qǐng)重新輸入按回車(chē)鍵繼續(xù):n");free(p);gets(lj);getchar();printf("請(qǐng)輸入員工的姓名:n");scanf("%s"p->name);printf("請(qǐng)輸入員工的年齡:n"

12、;);scanf("%d"&p->age);printf("請(qǐng)輸入員工的性別:n");scanf("%s"p->sex);printf("請(qǐng)輸入員工的出生年月:n");scanf("%s"p->birthday);printf("請(qǐng)輸入員工的電話:n");scanf("%s"p->tel);printf("請(qǐng)輸入員工的學(xué)歷:n");scanf("%s"p->edu);printf

13、("請(qǐng)輸入員工的職務(wù):n");scanf("%s"p->pos);printf("請(qǐng)輸入員工的住址:n");scanf("%s"p->add);insert(p);printf("輸入的員工信息為:n");printf("-:n");printf("編號(hào)tt姓名tt年齡tt性別tt出生年月tt電話tt學(xué)歷tt職務(wù)tt住址:n");display(p);printf("按回車(chē)鍵繼續(xù)n");writeDate();gets(lj

14、);getchar();void insert(struct emp *em)struct emp *p0*p1*p2;p1=head;p0=em;if(head=NULL)head=p0;p0->next=NULL;elsewhile(p0->num > p1->num)&&(p1->next!=NULL)p2=p1;p1=p1->next;if(p0->num<=p1->num)if(head=p1)head=p0;elsep2->next=p0;p0->next=p1;elsep1->next=p0;

15、p0->next=NULL;t+;void display(struct emp *p)printf("%ldtt%stt%dtt%stt%stt%stt%stt%stt%sn"p->nump->namep->agep->sexp->birthdayp->telp->edup->posp->add);void liebiao()char lj100;struct emp *p;p=head;system("cls");if(head=NULL)printf("查找不到信息n"

16、);menu();printf("員工信息列表n");printf("編號(hào)tt姓名tt年齡tt性別tt出生年月tt電話tt學(xué)歷tt職務(wù)tt住址 :n");if(head!=NULL)while(p!=NULL)display(p);p=p->next;printf("n按回車(chē)鍵返回主菜單n");gets(lj);void chaxun()char ilj100;int flog;time_t T;struct tm * timenow;time ( &T );timenow = localtime ( &T );

17、 flog=0;while(1)system("cls");printf("nnnnn");printf(" 員工信息查詢(xún)系統(tǒng)n");printf(" n");printf(" n");printf(" n");printf(" 1.按照編號(hào)查詢(xún) n");printf(" n");printf(" n");printf(" n");printf(" 2.按照姓名查詢(xún) n");p

18、rintf(" n");printf(" n");printf(" n");printf(" 3.按照生日查詢(xún) n");printf(" n");printf(" n");printf(" n");printf(" 0.退出管理系統(tǒng) n");printf(" n");printf(" n");printf(" n");printf(" n");printf(

19、" %s" asctime (timenow) );printf("請(qǐng)輸入您的選擇(數(shù)字0-3):n");scanf("%c"&i);gets(lj);if(lj0)i='a'switch(i)case '1':bianhao();break;case '2':xingming();break;case '3':shengri();break;case '0':flog=1;break;default:printf("輸入有誤請(qǐng)重新輸入n

20、");gets(lj);break;if(flog)break;void bianhao()int number;char lj100;struct emp *p1;p1=head;printf("請(qǐng)輸入要查詢(xún)員工的編號(hào):n");scanf("%d"&number);while(number!=p1->num)&&(p1->next!=NULL)p1=p1->next;if(number=p1->num)printf("員工信息查詢(xún)n");printf("要查詢(xún)的員工

21、信息:n");printf("編號(hào)tt姓名tt年齡tt性別tt出生年月tt電話tt學(xué)歷tt職務(wù)tt住址:n");printf("%ldtt%stt%dtt%stt%stt%stt%stt%stt%sn"p1->nump1->namep1->agep1->sexp1->birthdayp1->telp1->edup1->posp1->add);printf("按回車(chē)鍵繼續(xù)n");gets(lj);getchar();else if(p1->next=NULL)prin

22、tf("要查詢(xún)的員工信息不存在按回車(chē)鍵返回:n");gets(lj);getchar();void xingming() char ch10;struct emp *p;char lj100;p=head;printf("請(qǐng)輸入要查詢(xún)的員工的名字:n");scanf("%s"ch);if(p=NULL)printf("不存在員工記錄按回車(chē)鍵返回.n");gets(lj);getchar();return ;while(strcmp(chp->name)&&p->next!=NULL)p=

23、p->next;if(!strcmp(chp->name)printf("員工信息查詢(xún)n");printf("編號(hào)tt姓名tt年齡tt性別tt出生年月tt電話tt學(xué)歷tt職務(wù)tt住址:n");display(p);printf("按回車(chē)鍵繼續(xù)n");gets(lj);getchar();else if(p->next=NULL)printf("不存在員工記錄.n");gets(lj);getchar();return;void shengri() char bir20lj100;struct em

24、p *p;p=head;printf("請(qǐng)輸入要查詢(xún)的員工的出生日期:n");scanf("%s"bir);if(p=NULL)printf("不存在員工記錄.按回車(chē)鍵返回n");gets(lj);getchar();return ;while(strcmp(birp->birthday)&&p->next!=NULL)p=p->next;if(!strcmp(birp->name)printf("員工信息查詢(xún)n");printf("編號(hào)tt姓名tt年齡tt性別tt

25、出生年月tt電話tt學(xué)歷tt職務(wù)tt住址:n");display(p);printf("按回車(chē)鍵繼續(xù)n");gets(lj);getchar();else if(p->next=NULL)printf("不存在員工記錄.按回車(chē)鍵返回n");gets(lj);getchar();return;void readDate()FILE * fp;struct emp *p1*p2;fp=fopen(DATA "r");if(!fp)printf("打開(kāi)文件失敗!按回車(chē)鍵繼續(xù)n");getchar();el

26、sefscanf(fp"%dn"&t);head=p1=p2=(struct emp *)malloc(LEN);fscanf(fp"%ldtt%stt%dtt%stt%stt%stt%stt%stt%sn"&p1->nump1->name&p1->agep1->sexp1->birthdayp1->telp1->edup1->posp1->add);while(!feof(fp)p1=(struct emp *)malloc(LEN);fscanf(fp"%ldtt

27、%stt%dtt%stt%stt%stt%stt%stt%sn"&p1->nump1->name&p1->agep1->sexp1->birthdayp1->telp1->edup1->posp1->add);p2->next=p1;p2=p1;p2->next=NULL;fclose(fp);void writeDate()FILE* fp;struct emp *p1;fp=fopen(DATA "w");if(!fp)printf("打開(kāi)文件失敗!n");r

28、emove(fp);getchar();else fprintf(fp"%dn"t);for(p1=head;p1!=NULL;p1=p1->next)fprintf(fp"%ldtt%stt%dtt%stt%stt%stt%stt%stt%sn"p1->nump1->namep1->agep1->sexp1->birthdayp1->telp1->edup1->posp1->add);fclose(fp);void freeAll()struct emp *p1*p2;p1=p2=head;w

29、hile(p1)p2=p1->next;free(p1);p1=p2;void shanchu()struct emp *p1*p2;long int number;char lj100;if(head=NULL)printf("無(wú)員工紀(jì)錄!按回車(chē)鍵返回n");gets(lj);getchar();return;printf("請(qǐng)輸入你要?jiǎng)h除的員工的編號(hào):n");scanf("%ld"&number);p1=head;while(number!=p1->num&&p1->next!=NULL)

30、p2=p1;p1=p1->next;if(number=p1->num)if(p1=head)head=p1->next;else p2->next=p1->next;free(p1);t-;writeDate();printf("刪除成功按回車(chē)鍵繼續(xù)n");elseprintf("沒(méi)有該員工的紀(jì)錄請(qǐng)核對(duì).按回車(chē)鍵返回n");gets(lj);getchar();void xiugai()struct emp *p1*p2;long int number;char lj100;if(head=NULL)printf("無(wú)員工紀(jì)錄!按回車(chē)鍵返回n");gets(lj);getchar();return;printf("請(qǐng)輸入你要修改的員工的編號(hào):n");sca

溫馨提示

  • 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)論