超市員工管理系統(tǒng)_第1頁
超市員工管理系統(tǒng)_第2頁
超市員工管理系統(tǒng)_第3頁
超市員工管理系統(tǒng)_第4頁
超市員工管理系統(tǒng)_第5頁
已閱讀5頁,還剩10頁未讀, 繼續(xù)免費閱讀

下載本文檔

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

文檔簡介

1、超市員工管理系統(tǒng)#include include stdlib.h include windows.h /清屏函數(shù)頭文件 include number ); if(!strcmp(p-number ,) free(p); /釋放不需要的結(jié)構(gòu)體內(nèi)存 break; else +i; scanf(%sss%s%ss%s,pname ,psex ,pborth ,p-degree ,pbusiness ,p-phone ,pplace ); p-con0=0; /防止后面判斷出現(xiàn)隨機值 if(head=NULL) head=p; else while(q-next !=NULL) /防止結(jié)束后再次輸入

2、時出現(xiàn)問題 q=q-next ; q-next =p; q=p; /每次都加在鏈表尾 return head; /排序函數(shù) /輸入?yún)?shù):頭指針 void Sort(struct Stuff head) char ch; struct Stuff *p,q,r; while(1) printf(”請選擇排序條件:1。編號2.姓名3.性別4.出生年月5。學(xué)歷6.職務(wù)7。電話8.地址0.退出n”); scanf(” %c”,ch); if(ch=0) break; if(ch1|ch8) printf(”輸入錯誤,請重新輸入!n); continue; p=head; while(p-next!=N

3、ULL) /選擇排序 q=pnext; r=p; while(q!=NULL) if(Sel(ch,r,q) /調(diào)用判斷函數(shù) r=q; q=q-next; if(r!=p) /交換內(nèi)容 Scpy(r-number,pnumber); Scpy(r-name,p-name); Scpy(rsex,psex); Scpy(rborth,pborth); Scpy(r-degree,p-degree); Scpy(r-business,p-business); Scpy(r-phone,p-phone); Scpy(r-place,p-place); p=p-next; Prf(head); /輸出

4、 /交換函數(shù) void Scpy(char *p,char q) char c50; strcpy(c,p); strcpy(p,q); strcpy(q,c); /判斷函數(shù) /輸出參數(shù):1為真,0為假 int Sel(char ch,struct Stuff p,struct Stuff q) switch(ch) /實現(xiàn)各個關(guān)鍵字查找 case 1: return strcmp(q-number ,p-number )0|strcmp(qcon ,pnumber )=0 ; /排序條件及查找條件 case 2: return strcmp(q-name ,p-name )0|strcmp(

5、q-con ,p-name )=0 ; case 3: return strcmp(qsex ,p-sex )0strcmp(qcon ,psex )=0 ; case 4: return strcmp(q-borth ,p-borth)con ,p-borth )=0 ; case 5: return strcmp(qdegree ,p-degree )business ,p-business )0|strcmp(qcon ,p-business)=0 ; case 7: return strcmp(qphone ,pphone )con ,pphone)=0; case 8: return

6、 strcmp(qplace ,p-place )0|strcmp(q-con ,pplace )=0; default : exit(0); /查找函數(shù) struct Stuff *Ser(struct Stuff head) struct Stuff *p=NULL,q,a=0”,0,0”,0”,”0,0”,0,”0; /防止判斷時錯誤 int flag; /查找判斷 char ch,sh; q=&a; while(1) printf(請輸入要查找的條件:1.編號2。姓名3。性別4.出生年月5.學(xué)歷6。職務(wù)7。電話8。住址0。退出n); scanf( c,ch); if(ch=0) bre

7、ak; if(ch1|ch8) printf(輸入錯誤,請重新輸入!n); continue; fflush(stdin); printf(”請輸入:”); gets(q-con ); p=head; /指向表頭 flag=0; while(p!=NULL) if(Sel(ch,p,q)) printf(”員工信息如下:n”); printf( 編號 | 姓名 性別 | 出生年月 | 學(xué)歷 | 職務(wù) | 電話 | 住址 ns s %s %s %s %s %s sn” ,pnumber ,pname ,p-sex ,p-borth ,p-degree ,pbusiness ,p-phone ,p

8、-place ); printf(是否需要:1.更改 2.刪除 3。繼續(xù)n); scanf(” c,sh); if(sh=1) Chn(head,pnumber); /調(diào)用更改函數(shù) else if(sh=2) head=Del(head,pnumber); /調(diào)用刪除函數(shù),得到的head必須return flag=1; break; p=p-next ; if(flag=0) printf(沒有找到該員工信息!n); return head; /更改函數(shù) /輸入?yún)?shù):n10 為員工編號 void Chn(struct Stuff *head,char n10) struct Stuff p=h

9、ead; int flag=0; if(head=NULL) printf(”未找到員工信息!n); else while(p!=NULL) if(!strcmp(p-number,n) printf(”請輸入新的信息:n編號姓名性別出生年月|學(xué)歷|職務(wù)電話|住址n); scanf(”%s%s%sss%s%ss”,pnumber ,p-name ,p-sex ,p-borth ,p-degree ,pbusiness ,p-phone ,pplace ); printf(員工信息如下:n”); flag+; break; p=pnext; if(flag=0) printf(”未找到該員工信息

10、!n); Prf(head); /刪除函數(shù) /輸入?yún)?shù):n為員工編號 /輸出參數(shù):頭指針 struct Stuff *Del(struct Stuff *head,char n10) struct Stuff *p,pr; int flag; flag=0; p=head,pr=head; if(head=NULL) printf(”未找到員工信息!n”); else while(strcmp(pnumber ,n)&pnext !=NULL) pr=p; p=p-next ; if(!strcmp(p-number ,n) if(p=head) head=pnext ; else pr-next=p-next ; free(p); printf(”刪除成功!n”); i; else printf(未找到員工信息!n”); Prf(head); return head; /輸出函數(shù) void Prf(struct Stuff head) struct Stuff p=head; int i=1; while(p!=NULL) printf(d。 s s s %s s s s sn ,i+,p-number ,pnam

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

評論

0/150

提交評論