職工檔案管理c語言程序設(shè)計(jì)_第1頁
職工檔案管理c語言程序設(shè)計(jì)_第2頁
職工檔案管理c語言程序設(shè)計(jì)_第3頁
職工檔案管理c語言程序設(shè)計(jì)_第4頁
職工檔案管理c語言程序設(shè)計(jì)_第5頁
已閱讀5頁,還剩15頁未讀, 繼續(xù)免費(fèi)閱讀

下載本文檔

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

文檔簡介

1、project design. construction preparation phase and construction tender approval for project administration procedures project site level. project implementation schedule in figure 2, the implementation of control measures (a .7、tender procedures (a) invites tenders for the project in accordance with

2、 the relevant provisions of the state to comply with the project approval procedure, after obtaining the approval of public tenders. publish tender notices tender specified media. notice shall set forth the name and address of the tenderer, the nature, quantity, implementation of the project locatio

3、n and the times and ways to obtain tender documents and other items. this item should include the tender project of technical requirements, bidder eligibility criteria, bid requirements and evaluation standards of all substantive requirements and intends to sign the contracts terms and conditions. (

4、b) investigation and design bidding is the entire basis of the project of investigation and design work. public tender of project design, public choice of investigation and design units, the project design is building professional grade b or above qualification of bidders. (c) quality of tendering a

5、nd construction supervision for engineering construction supervision plays a key role. at the time of construction supervision of tendering and public supervision of project construction management enterprises. this project require bidders to have construction engineering grade b or above qualificat

6、ion. (d) the construction enterprise bidding engineering needs require bidders to have construction grade or above qualification. (e) main material procurement according to the projects needs, public choice major material suppliers, equipment, technology and material quality of the bidders shall con

7、form to the design requirements of this project, high quality and low price and reliable after-sales service. potential bidders to the project site. the tender documents issued from the date of the item to the bidder submitting the tender closing date, the shortest shall not be less than 20th. 8 bid

8、ding this item the bidder should have the capacity to undertake the project, preparation of tender documents and shall be in accordance with the requirements of the tender documents. the bid documents shall respond to substantive requirements and conditions for tender documents. bidders shall tender

9、 prior to the deadline for submission of bid documents, the tender documents the place. less than three bidders, the tenderer shall, in accordance with the way new. bidders bid after the bid project part of the non-principal, critical work to subcontractors shall be set out in the tender documents.

10、bidders shall not collude with the tender offer, and may not crowd out other bidders, fair competition, and must not harm the tenderer or bidders legitimate rights and interests. bidders not c語言程序設(shè)計(jì)課程設(shè)計(jì)任務(wù)書設(shè)計(jì)題目:職員檔案管理一 已知技術(shù)參數(shù)與設(shè)計(jì)前提員工人數(shù)1000人,對(duì)這1000人進(jìn)行人員調(diào)動(dòng),管理二 設(shè)計(jì)內(nèi)容及要求1 創(chuàng)建與顯示職工檔案2 查詢與修改職工檔案3 添加與刪除職工檔案4 排

11、序職工檔案三課程設(shè)計(jì)工作計(jì)劃1、確定題目,成立設(shè)計(jì)小組,做用戶需求分析(3天)2、查閱資料,進(jìn)行問題分析,制定方案,確定成員分工(3天)3、根據(jù)方案編寫程序并進(jìn)行調(diào)試(2天)4、撰寫設(shè)計(jì)說明書,完成設(shè)計(jì)(3天)5、提交設(shè)計(jì)內(nèi)容,答辯四、相關(guān)教材及參考書目1、c語言程序設(shè)計(jì) 高等教育出版社2、the c programming language 機(jī)械工業(yè)出版社 指導(dǎo)教師簽字: 系主任 簽字 : 年 月 日目 錄一、需求分析4二、人員分工5三、系統(tǒng)運(yùn)行環(huán)境5四、系統(tǒng)模塊功能5五、使用說明7六、程序源代碼14參考文獻(xiàn)10教師評(píng)語22職員管理系統(tǒng)使用說明書一、需求分析在電子信息高度發(fā)達(dá)的時(shí)代,時(shí)間就是

12、金錢,運(yùn)用計(jì)算機(jī)系統(tǒng)對(duì)職工檔案進(jìn)行管理能夠提高管理效率,節(jié)約時(shí)間,才會(huì)在有效的時(shí)間里創(chuàng)造更多的財(cái)富。利用該系統(tǒng)可以對(duì)工人的編號(hào)、姓名、電話、薪水、家庭住址等信息進(jìn)行管理,方便高效。職工檔案管理是一項(xiàng)非常繁瑣的業(yè)務(wù),用計(jì)算機(jī)實(shí)現(xiàn)自動(dòng)化管理既可以減輕管理人員的勞動(dòng)強(qiáng)度,又可以提高管理效率.欲編寫一個(gè)比較實(shí)用的職工檔案管理程序,應(yīng)包括以下幾個(gè)方面的功能:建立管理檔案,修改職工信息,刪除離職職工信息,增加新的職工信息,查找職工信息,對(duì)職工信息進(jìn)行排序.在查找和刪除職工信息時(shí),要選擇按姓名查詢還是按編號(hào)查詢進(jìn)行操作,這要用到文件存儲(chǔ)數(shù)據(jù)結(jié)構(gòu),數(shù)據(jù)結(jié)構(gòu)的構(gòu)造類型選擇結(jié)構(gòu)體類型,包括結(jié)構(gòu)體變量,結(jié)構(gòu)體數(shù)組,

13、結(jié)構(gòu)體指針.基本類型有整型和字符型,其中字符型用來定義職工編號(hào),姓名,薪水,電話,家庭住址.二、人員分工姓名主要負(fù)責(zé)內(nèi)容xxx(組長)總體設(shè)計(jì);管理檔案的創(chuàng)建和顯示的設(shè)計(jì)和編譯.xxx職工檔案的查詢和修改的設(shè)計(jì)和編譯.xxx職工檔案的添加和刪除的設(shè)計(jì)和編譯xxx職工檔案的排序和退出的設(shè)計(jì)和編譯.三、運(yùn)行環(huán)境硬件環(huán)境: cpu(pentium4 2.4hz)、內(nèi)存(256mb)、硬盤(80g)軟件環(huán)境:windows 98、 tubro.c 2.0四、系統(tǒng)模塊功能1、系統(tǒng)總體框模 塊 能 功 1創(chuàng)建職工2顯示職工3查詢職工4修改職工5添加職工6刪除職工職工檔案4修改職工檔案5添加職工檔案6刪除職

14、工檔7職工信息 排案7排序職工2、模塊設(shè)計(jì)創(chuàng)建模塊:該模塊功能是創(chuàng)建管理檔案。在chuangjian()函數(shù)中定義整型變量i,結(jié)構(gòu)體變量temp,和文件指針fp,以“w”的方式打開“jilu”文件,如果fp指向null,說明打開方式失敗。否則,輸入第一個(gè)記錄,包括編號(hào)、姓名、電話、薪水、家庭住址等。直到遇見#”結(jié)束錄入。最后關(guān)閉文件。顯示模塊:該模塊功能是顯示管理檔案。在xianshi()函數(shù)中定義變量 n 初值為0,用來記錄文件中寫入的數(shù)目。定義結(jié)構(gòu)體變量temp和文件指針fp,以“r”方式打開文件“jilu”。如果fp指向null,則文件打開失敗。否則依次輸入編號(hào)、姓名、電話、薪水、家庭住

15、址等。每輸入一次使n值增1。最后,如果n為0說明文件中沒有記錄,否則輸出文件中有n個(gè)記錄。最后關(guān)閉文件。查詢模塊:該模塊功能是查詢管理檔案。在chaxun()函數(shù)中定義字符變量c,用來選擇按編號(hào)查詢還是按姓名查詢。定義文件指針fp,以“r”的方式打開”jilu”文件,如果fp指向null,則打開文件失敗。否則輸入“h”或“h”選擇按編號(hào)查詢,或者輸入“m”或“m”選擇按姓名查詢。如果按姓名查詢則調(diào)用chaxun_name()函數(shù),定義整型變量flag,控制文件中是否確有此人。定義整型變量n初值為,用來說明文件中是否有記錄。定義字符數(shù)組temp,用來輸入該姓名下的記錄。輸入姓名后,如果n值為0說

16、明文件中沒有記錄 ,如果flag為0說明文件中沒有此人。如果按編號(hào)查詢則調(diào)用chaxun_num()函數(shù),定義整型變量flag,控制文件中是否確有此人。定義整型變量n初值為,用來說明文件中是否有記錄。定義字符數(shù)組temp,用來輸入該編號(hào)下的記錄。輸入編號(hào)后,如果n值為0說明文件中沒有記錄 ,如果flag為0說明文件中沒有此人。最后關(guān)閉文件。修改模塊 :該模塊功能是修改管理檔案。在xiugai()函數(shù)中定義字符變量c用來確定當(dāng)輸入編號(hào)重復(fù)時(shí)是否要重新輸入。定義整型變量n記下文件中記下的數(shù)目。定義結(jié)構(gòu)體指針變量find、p,結(jié)構(gòu)體數(shù)組record,結(jié)構(gòu)體變量temp.以“r”方式打開文件“jilu

17、”,使p指向record首地址。每讀入一個(gè)記錄使n值增1,把p賦給find,讓find記住修改位置。如果p指向record+n,說明記錄中沒有此人。則需要輸入另一個(gè)編號(hào),如果編號(hào)重復(fù),則用”y”或”y”或”n”或”n”選擇是否要重新輸入編號(hào)。用find找到需要修改的記錄的位置,進(jìn)行修改。最后關(guān)閉文件。添加模塊:該模塊功能是添加管理檔案.在tianjia ()函數(shù)中定義字符變量c,用來選擇當(dāng)輸入編號(hào)重復(fù)時(shí)是否要重新輸入。定義整型變量n用來記下錄入數(shù)目。定義結(jié)構(gòu)體變量temp,結(jié)構(gòu)體數(shù)組record,結(jié)構(gòu)體指針p。定義文件指針fp,指向文件“jilu”。當(dāng)fp沒有指向文件末尾時(shí),把添加的記錄寫到f

18、p所指文件中。如果編號(hào)重復(fù),用“n”或“n”選擇放棄,用“y”或“y”選擇重新輸入,進(jìn)行輸入。最后關(guān)閉文件。刪除模塊:該模塊功能是刪除管理檔案信息。在shanchu()函數(shù)中定義字符變量c,用來接收“h”或“h”選擇按編號(hào)刪除,接受“m”或“m”選擇按姓名刪除。定義文件指針fp指向文件“jilu”。如果選擇按編號(hào)刪除,則調(diào)用shanchu_num()函數(shù),定義字符數(shù)組tempnum10,定義整型變量n初值為0,定義結(jié)構(gòu)體數(shù)組rcordn,結(jié)構(gòu)體指針p,k。使p指向要?jiǎng)h除記錄,當(dāng)k小于record+n時(shí)進(jìn)行刪除操作。否則輸出無記錄。如果選擇按姓名刪除,則調(diào)用shanchu_name()函數(shù),定義

19、字符數(shù)組tempname10,定義整型變量n初值為0,定義結(jié)構(gòu)體數(shù)組rcordn,結(jié)構(gòu)體指針p,k。使p指向要?jiǎng)h除記錄,當(dāng)k小于record+n時(shí)進(jìn)行刪除操作。否則輸出無記錄。最后關(guān)閉文件。 排序模塊:該模塊功能是排序職工檔案。在paixu()函數(shù)中定義字符變量c,用來選擇按編號(hào)排序還是按姓名排序。定義整型變量i,j,k,n使n初值為0,用來記下寫入記錄數(shù)目。 定義結(jié)構(gòu)體數(shù)組record,結(jié)構(gòu)體指針p,結(jié)構(gòu)體變量temp,定義文件指針fp,指向文件“jilu”。使p指向record的第一個(gè)記錄,選擇“s”或“s”按升序排列,選擇“j”或“j”選擇按降序排列。按所選擇的方式排列。最后關(guān)閉文件。退

20、出模塊:該模塊功能是退出管理檔案。五、使用說明啟動(dòng)后屏幕上會(huì)提示登陸成功以及顯示下面菜單,如果想要執(zhí)行某項(xiàng)功能只需按對(duì)應(yīng)的數(shù)字即可。 職工檔案的創(chuàng)建:在主菜單中輸入1則系統(tǒng)會(huì)進(jìn)入新界面并自動(dòng)提示你“請(qǐng)出入第一個(gè)記錄”,完成后按回車鍵系統(tǒng)會(huì)逐一提示輸入編號(hào)、姓名、電話號(hào)碼、薪水、住址。輸入所建立職工檔案后選擇y(繼續(xù)進(jìn)行),系統(tǒng)返回主菜單。 職工檔案的顯示:在主菜單中輸入2則系統(tǒng)會(huì)進(jìn)入新界面,如圖所示:職工檔案的查詢:在主菜單中輸入3 則進(jìn)入查詢子菜單界面,此時(shí)在界面會(huì)提示你“按編號(hào)查詢(h),還是按姓名查詢(m)?”。輸入h后則進(jìn)入按編號(hào)查詢職工檔案信息,此時(shí)系統(tǒng)會(huì)自動(dòng)提示你輸入“你要查詢的職

21、工的編號(hào)”。輸入編號(hào)后后會(huì)出現(xiàn)該職工的信息,輸入m則按職工姓名查詢。輸入錯(cuò)誤信息,顯示查無此人。職工檔案的修改:在主菜單中輸入4,系統(tǒng)會(huì)自動(dòng)提示你“請(qǐng)輸入所要修改記錄的編號(hào)”,輸入新的編號(hào)后按回車鍵,按提示逐一輸入所要修改的內(nèi)容。職工檔案的添加:在主菜單中輸入5,進(jìn)入后,系統(tǒng)會(huì)自動(dòng)提示你要輸入職工的信息,按照編號(hào)、姓名、電話號(hào)碼、薪水、住址輸入格式:輸入職工的信息。職工檔案的刪除:在主菜單中輸入6,系統(tǒng)界面會(huì)提示你“按編號(hào)刪除(h),還是按姓名刪除(m)?”。輸入h則按編號(hào)刪除記錄,輸入m則按姓名刪除記錄,輸入錯(cuò)誤信息顯示 “對(duì)不起,無此人記錄!”。 職工檔案的排序:在主菜單中輸入7,系統(tǒng)會(huì)自

22、動(dòng)提示你“按編號(hào)排序(h),按姓名排序(m)?”,輸入h后系統(tǒng)會(huì)自動(dòng)提示你“按升序(s),還是按降序(j)?”,輸入s,系統(tǒng)會(huì)自動(dòng)按升序排列并顯示排列后職工檔案信息。 退出系統(tǒng): 在主菜單中輸入0,系統(tǒng)會(huì)自動(dòng)退出改程序。 注意事項(xiàng):運(yùn)行本程序之前,應(yīng)當(dāng)先運(yùn)行附帶的子程序(mima),為文件mima.date賦初值?;?。六、源程序代碼職工檔案管理源程序 #include #include #include /*函數(shù)clrscr()及getch()等的頭文件*/#define n 100struct student char num10; char name10;char tel10;char s

23、alary10;char address21; ;void shuchu();void chuangjian();void xianshi();void chaxun();/*函數(shù)chaxun_num與chaxun_name函數(shù)被chaxun調(diào)用*/void chaxun_num(file *fp);void chaxun_name(file *fp);void xiugai();void tianjia();void shanchu();/*函數(shù)shanchu_num與shanchu_name函數(shù)被mydelete調(diào)用*/void shanchu_num(file *fp);void sha

24、nchu_name(file *fp);void paixu();void sort_num();void sort_name();main()char choose,yes_no; do shuchu();/*顯示菜單*/ printf( 請(qǐng)選擇序號(hào)操作: ); choose=getch(); /*函數(shù)getch()的功能是從鍵盤上讀入一個(gè)單獨(dú)的字符,字符不回顯在屏幕上*/ switch(choose) case 1:chuangjian();break; case 2:xianshi();break; case 3:chaxun();break; case 4:xiugai();break

25、; case 5:tianjia();break; case 6:shanchu();break; case 7:paixu();break; case 0:break; default:printf(n %c違法選項(xiàng)!n,choose); if(choose=0) break; printf(n 要繼續(xù)選擇嗎(y/n)?n); do yes_no=getche(); while(yes_no!=y & yes_no!= y & yes_no!=n & yes_no!=n);while(yes_no=y| yes_no=y);void shuchu() /*顯示菜單界面*/clrscr();p

26、rintf(nnnnnn);printf( | -你好歡迎使用-|n);printf( | 請(qǐng)輸入選項(xiàng)編號(hào)(07): |n);printf( |-|n);printf( | 1-職工檔案的創(chuàng)建 |n);printf( | 2-職工檔案的顯示 |n);printf( | 3-職工檔案的查詢 |n);printf( | 4-職工檔案的修改 |n);printf( | 5-職工檔案的添加 |n);printf( | 6-職工檔案的刪除 |n);printf( | 7-職工檔案的排序 |n);printf( | 0-退出 |n);printf( |-|n);/*創(chuàng)建模塊*/*定義創(chuàng)建職工檔案的函數(shù)*/

27、void chuangjian()int i,n=0;struct student temp,stun;file *fp; /*定義fp為文件指針*/for(i=0;i100;i+) printf(n 請(qǐng)輸入第 %d 個(gè)記錄:n,i+1); printf( 編號(hào)(用 # 號(hào)結(jié)束輸入):);scanf(%s,&stui.num); printf( 姓名(用 # 號(hào)結(jié)束輸入):);scanf(%s,&); printf( 電話號(hào)碼(用 # 號(hào)結(jié)束輸入):);scanf(%s,&stui.tel); printf( 薪水(用 # 號(hào)結(jié)束輸入) :);scanf(%s,&stui.s

28、alary); printf( 住址(用 # 號(hào)結(jié)束輸入):); scanf(%s,&stui.address); if(stui.num0=#|0=#|stui.tel0=#|stui.salary0=#|stui.address0=#) break; n+; fp=fopen(jilu.dat,w);if(fp=null)printf(n 打開文件失敗!n);return;for(i=0;in;i+) if(fwrite(&stui,sizeof(struct student),1,fp)!=1) /*把結(jié)構(gòu)體數(shù)組stui寫入以fp為指針的文件中*/ printf( 文件

29、寫入出錯(cuò)!n);fclose(fp);/*顯示模塊*/*定義顯示職工檔案的函數(shù)*/void xianshi() int n=0,i=0;struct student stun;file *fp;fp=fopen(jilu.dat,r);if(fp=null) printf(n 打開文件失敗!n);return;clrscr();printf( 編號(hào) 姓名 電話號(hào)碼 薪水 住址n);while(feof(fp)=0) fread(&stui,sizeof(struct student),1,fp); /*從以fp為指針的文件中讀取數(shù)據(jù)賦給結(jié)構(gòu)體數(shù)組stui*/ +i;+n; if(n=0) pr

30、intf(n 文件無記錄!n);else for(i=0;in-1;i+) printf(%12s%12s%12s%12s%12sn,stui.num,,stui.tel,stui.salary,stui.address); printf(n 文件總共有 %d 個(gè)記錄!n,n-1); fclose(fp);/*查詢模塊*/*定義查詢職工檔案的函數(shù)*/void chaxun()char c;file *fp;fp=fopen(jilu.dat,r);if(fp=null) printf(n 打開文件失敗!n);return;printf(n 按編號(hào)查詢(h), 還是按姓名查詢(

31、m)?);c=getche();if(c=h|c=h) chaxun_num(fp);else if(c=m|c=m) chaxun_name(fp); else printf(n 非法字符!n);fclose(fp);/*定義按編號(hào)查詢職工檔案的函數(shù)*/void chaxun_num(file *fp)int flag=0,n=0;char tempnum10;struct student temp;printf(n 請(qǐng)輸入要查詢記錄的編號(hào):);scanf(%s,tempnum);while(feof(fp)=0) fread(&temp,sizeof(struct student),1,f

32、p); n+; if(strcmp(tempnum,temp.num)=0) if(flag=0) printf( 編號(hào) 姓名 電話號(hào)碼 薪水 住址n); printf(%12s%12s%12s%12s%12sn,temp.num,,temp.tel,temp.salary,temp.address);flag=1; break; if(n=0) printf(n 文件中無記錄!n);else if(flag=0) printf(n 文件中無此記錄!n);/*定義按姓名查詢職工檔案的函數(shù)*/void chaxun_name(file *fp)int flag=0,n=0;ch

33、ar tempname10;struct student temp;printf(n 請(qǐng)輸入要查詢記錄的姓名:);scanf(%s,tempname);while(feof(fp)=0) fread(&temp,sizeof(struct student),1,fp); n+; if(strcmp(tempname,)=0) if(flag=0) printf( 編號(hào) 姓名 電話號(hào)碼 薪水 住址n); printf(%12s%12s%12s%12s%12sn,temp.num,,temp.tel,temp.salary,temp.address); flag

34、=1; break; if(n=0) printf(n 文件中無記錄!n);else if(flag=0) printf(n 文件中無此人!n);/*修改模塊*/*定義修改職工檔案的函數(shù)*/void xiugai()char c; int n=0,i=0;struct student *find,temp,stun,*p;file *fp;fp=fopen(jilu.dat,r);if(fp=null) printf(n 打開文件失敗!n);return;while(feof(fp)=0) fread(&stui,sizeof(struct student),1,fp);i+;n+; fclo

35、se(fp); if(n=0) printf(n 文件中無記錄!n);return; printf(n 請(qǐng)輸入要修改記錄的編號(hào):);gets(temp.num); for(p=stu;pnum)=0) find=p;break; if(p=stu+n) printf(n 無此人!n);return; do printf(n 請(qǐng)輸入正確的編號(hào):); do gets(temp.num); while(strcmp(temp.num,)=0); printf( 請(qǐng)輸入正確的姓名:);gets();printf( 請(qǐng)輸入正確的電話號(hào)碼:);gets(temp.tel);printf(

36、 請(qǐng)輸入正確的薪水:);gets(temp. salary);printf( 請(qǐng)輸入正確的住址:);gets(temp.address); for(p=stu;pnum)=0)& (p!=find) printf(n 編號(hào)重復(fù), 要重新輸入嗎(y/n)?); do c=getche(); while(c!=y&c!=y&c!=n&c!=n);putchar(n); break; if(p=stu+n) *find=temp; break; while(c=y|c=y);fp=fopen(jilu.dat,w);if(fp=null)printf(n 打開文件失敗!n);return;for(p

37、=stu;pstu+n-1;p+) if(fwrite(p,sizeof(struct student),1,fp)!=1) printf( 文件寫入出錯(cuò)n);fclose(fp);/*添加模塊*/*定義添加職工檔案的函數(shù)*/void tianjia() char c;int n=0,i=0;struct student temp,stun;file *fp;fp=fopen(jilu.dat,r);if(fp=null) printf(n 打開文件失敗!n);return;while(feof(fp)=0) fread(&stui,sizeof(struct student),1,fp);i

38、+;n+;fclose(fp);do printf(n 請(qǐng)輸入新記錄的編號(hào):); do scanf(%s,temp.num); while(strcmp(temp.num,)=0); printf( 請(qǐng)輸入新記錄的姓名:);scanf(%s,); printf( 請(qǐng)輸入新記錄的電話號(hào)碼:);scanf(%s,temp.tel);printf( 請(qǐng)輸入新記錄的薪水:);gets(temp. salary);printf( 請(qǐng)輸入新記錄的住址:);gets(temp.address); for(i=0;in-1;i+) if(strcmp(temp.num,stui.num)=0

39、) printf(n 編號(hào)重復(fù) ,要重新輸入嗎(y/n)?); do c=getche(); while(c!=y& c!=y& c!=n &c!=n); putchar(n); break; if(i=n-1)stui=temp;break;while(c=y|c=y);fp=fopen(jilu.dat,w);if(fp=null) printf(n 打開文件失敗!n);return;for(i=0;in;i+) if(fwrite(&stui,sizeof(struct student),1,fp)!=1) printf(文件寫入出錯(cuò)n);fclose(fp);/*刪除模塊*/*定義刪除

40、通信錄的函數(shù)*/void shanchu()char c;file *fp;fp=fopen(jilu.dat,r);if(fp=null) printf(n 打開文件失敗!n);return;printf(n 按編號(hào)刪除(h), 還是按姓名刪除(m)?);c=getche();if(c=h|c=h) shanchu_num(fp);else if(c=m|c=m) shanchu_name(fp);else printf(n 非法字符!n);fclose(fp);/*定義按編號(hào)刪除通信錄的函數(shù)*/void shanchu_num(file *fp)char tempnum10;int n=0

41、,i=0,k;struct student stun;while(feof(fp)=0) fread(&stui,sizeof(struct student),1,fp);i+;n+;fclose(fp);printf(n 請(qǐng)輸入要?jiǎng)h除記錄的編號(hào):);scanf(%s,tempnum);for(i=0;in-1;i+) if(strcmp(tempnum,stui.num)=0) break; /*找到要?jiǎng)h除記錄結(jié)束循環(huán)*/if(in-1) /*提前結(jié)束循環(huán),說明找到此人*/ for(k=i;kn-1;k+) /*向左移一位,相當(dāng)于刪除記錄*/ stuk=stuk+1;else printf(

42、n 無此人!n);fp=fopen(jilu.dat,w);if(fp=null) printf(n 打開文件失敗!n);return;for(i=0;in-2;i+) if(fwrite(&stui,sizeof(struct student),1,fp)!=1) printf( 文件寫入出錯(cuò)n);fclose(fp);/*定義按姓名刪除職工檔案的函數(shù)*/void shanchu_name(file *fp)char tempname10;int n=0,i=0,k;struct student stun;while(feof(fp)=0) fread(&stui,sizeof(struct

43、 student),1,fp);i+;n+;fclose(fp);printf(n 請(qǐng)輸入要?jiǎng)h除記錄的姓名:);scanf(%s,tempname);for(i=0;in-1;i+) if(strcmp(tempname,)=0)break; /*找到要?jiǎng)h除記錄結(jié)束循環(huán)*/if(in-1) for(k=i;kn-1;k+) /*刪除記錄*/ stuk=stuk+1;else printf(n 無此人!n);fp=fopen(jilu.dat,w);if(fp=null) printf(n 打開文件失敗!n);return;for(i=0;in-2;i+) if(fwrite(&stui,sizeof(struct student),1,fp)!=1) printf( 文件寫入出錯(cuò)n);fclose(fp);/*排序模塊*/*定義排序職工檔案的函數(shù)*/void paixu()char c;file *fp;fp=fopen(jilu.dat,r);if(fp=null) printf(n 打開文件失敗!n);return;fclose(fp);printf(n 按編號(hào)排序(h), 還是按姓名排序(m)?);c=getche();if(c=h|c=h) sort_num(); /*按編號(hào)排序*/else if(c=m|c=m) sort_nam

溫馨提示

  • 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. 人人文庫網(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ì)自己和他人造成任何形式的傷害或損失。

最新文檔

評(píng)論

0/150

提交評(píng)論