職工工作量統(tǒng)計系統(tǒng)_第1頁
職工工作量統(tǒng)計系統(tǒng)_第2頁
職工工作量統(tǒng)計系統(tǒng)_第3頁
職工工作量統(tǒng)計系統(tǒng)_第4頁
職工工作量統(tǒng)計系統(tǒng)_第5頁
已閱讀5頁,還剩13頁未讀, 繼續(xù)免費閱讀

下載本文檔

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

文檔簡介

1、一、課程設(shè)計的內(nèi)容職工工作量統(tǒng)計系統(tǒng) 編寫有一個程序, 該程序輸入職工工號和完成的產(chǎn)品數(shù)量, 程序允許同一 職工有多次輸 入,由程序?qū)ζ渫瓿傻漠a(chǎn)品數(shù)量實現(xiàn)累計。 程序按完成數(shù)量對他們排序, 弁確定他們的名次。 按完成的產(chǎn)品數(shù)量由多到少的順序,輸出名次、同一名次的職工人數(shù)及他們的工號(工號由小到大順序輸出)。要求程序用有序鏈表存儲數(shù)據(jù)信息。二、課程設(shè)計的要求與數(shù)據(jù)1、進(jìn)一步掌握和利用 C語言進(jìn)行程設(shè)計的能力;2、進(jìn)一步理解和運用結(jié)構(gòu)化程序設(shè)計的思想和方法;3、初步掌握開發(fā)一個小型實用系統(tǒng)的基本方法;4、學(xué)會調(diào)試一個較長程序的基本方法;5、學(xué)會利用流程圖或 N-S圖表示算法;6、掌握書寫程序設(shè)計開

2、發(fā)文檔的能力。三、課程設(shè)計應(yīng)完成的工作1、編寫完成相應(yīng)題目的程序;2、編寫課程設(shè)計報告,課程設(shè)計報告的內(nèi)容應(yīng)包括以下 6個部分:1)需求分析:包括設(shè)計題目、設(shè)計要求以及系統(tǒng)功能需求分析;2)總體設(shè)計:包括系統(tǒng)總體設(shè)計框架和系統(tǒng)功能模塊圖;3)詳細(xì)設(shè)計:包括主要功能模塊的算法設(shè)計思路以及對應(yīng)的工作流程圖;4)調(diào)試分析過程描述:包括測試數(shù)據(jù)、測試輸出結(jié)果,以及對程序調(diào)試過程中存在問題的思考(列出主要問題的出錯現(xiàn)象、出錯原因、解決方法及效果等,適當(dāng)?shù)陌Y(jié)果截圖);5)總結(jié):課程設(shè)計完成了哪些功能,有沒有什么擴(kuò)展功能?還有哪些地方需要改進(jìn)?課程設(shè)計過程中的學(xué)習(xí)體會與收獲、對本次課程設(shè)計的認(rèn)識以及自己

3、的建議等內(nèi)容;6)附錄:主要源程序代碼,含必要的注釋。3、答辯:在實驗室建立程序運行的環(huán)境,并在指導(dǎo)教師的監(jiān)督下,獨立解決問題、運行程序和回答教師提出的問題。四、課程設(shè)計進(jìn)程安排序號設(shè)計各階段內(nèi)容地點起止日期1下達(dá)任務(wù)書,說明設(shè)計要求;收集資料實驗3#5176.182總體方案設(shè)計、詳細(xì)設(shè)計實驗3#5176.193編寫程序,調(diào)試分析實驗3#5176.204撰寫報告并上交,答辯實驗3#5176.21五、應(yīng)收集的資料及主要參考文獻(xiàn)1 譚浩強(qiáng).C程序設(shè)計(第三版)M,北京:清華大學(xué)出版社,2005.92 譚浩強(qiáng).C程序設(shè)計題解與上機(jī)指導(dǎo)(第三版)M,北京:清華大學(xué)出版社,2005.73 宋箭.C語言程

4、序設(shè)計,上海,上??茖W(xué)普及出版社,2005.64周啟海.C語言程序設(shè)計教程,北京,機(jī)械工業(yè)出版社,2004.1發(fā)出任務(wù)書日期:2007年6月18日指導(dǎo)教師簽名:計劃完成日期: 2007年6月22日基層教學(xué)單位責(zé)任人簽章:主管院長簽章:1設(shè)計目的與要求 頁碼2總體設(shè)計 頁碼3詳細(xì)設(shè)計 頁碼3.1 功能模塊設(shè)計 頁碼3.2 數(shù)據(jù)結(jié)構(gòu)設(shè)計 頁碼4調(diào)試分析 頁碼5總結(jié) 頁碼6附錄 頁碼6答辯記錄(正文處留出適當(dāng)空白) 頁碼7指導(dǎo)教師意見(正文處留出十行空白) 頁碼1 .目的與要求目的:將理論教學(xué)中涉及到的知識點貫穿起來,對不同的數(shù)據(jù)類型、程序控制結(jié)構(gòu)、數(shù)據(jù)結(jié)構(gòu)作一比較和總結(jié),結(jié)合設(shè)計題目進(jìn)行綜合性應(yīng)用

5、,對所學(xué)知識達(dá)到融會貫通的程度。利用面向過程的編程思想以及 C的編程方法完成系統(tǒng)的設(shè)計;進(jìn)一步培養(yǎng)學(xué)生綜合應(yīng)用C的各種編程知識和技巧進(jìn)行 Windows應(yīng)用程序編寫的實際能力,包括: (1)對C基本語法的 熟練掌 握;(2)訓(xùn)練學(xué)生對一個實際應(yīng)用系統(tǒng)進(jìn)行綜合分析、設(shè)計、編程及調(diào)試等的能力;(3)培養(yǎng)學(xué)生自主學(xué)習(xí)和獨立創(chuàng)新的精神。要求:1) 對于給定的設(shè)計題目,如何進(jìn)行分析,理清思路,弁給出相應(yīng)的數(shù)學(xué)模型。2) 掌握自頂而下的設(shè)計方法,將大問題進(jìn)行模塊化,領(lǐng)會結(jié)構(gòu)化程序設(shè)計的方法。3) 熟練掌握C語言的基本語法,靈活運用各種數(shù)據(jù)類型。4) 進(jìn)一步掌握在集成環(huán)境下如何調(diào)試程序(單步調(diào)試,設(shè)置斷點、

6、觀察表達(dá)式,分塊調(diào)試)和修改程序。設(shè)計的具體內(nèi)容:編寫有一個程序,該程序輸入職工工號和完成的產(chǎn)品數(shù)量,程序允許同一職工有多次輸入,由程序?qū)ζ渫瓿傻漠a(chǎn)品數(shù)量實現(xiàn)累計。程序按完成數(shù)量對他們排序,弁確定他們的名次。按完成的產(chǎn)品數(shù)量由多到少的順序,輸出名次、同一名次的職工人數(shù)及他們的工號(工號由小到大順序輸出)。要求程序用有序鏈表存儲數(shù)據(jù)信息。2總體設(shè)計1»準(zhǔn)備.1) 要求對序鏈表的使用具有較熟練的能力。2) 用到數(shù)組、指針方面的重要知識。3)函數(shù)的循環(huán)連續(xù)使用。2»概要設(shè)計.1,插入鏈表的節(jié)點先按照產(chǎn)品數(shù)量的多少排序(從多到少),如果產(chǎn)品的數(shù)量相等,就按照員工編號來排序(從小到大

7、)2,如果產(chǎn)品數(shù)量相等的,他們的序號是相同的 系統(tǒng)菜單/選才i J1.改變員工信息|2?刪除員工編號3.退出系統(tǒng)4?查詢輸入員工編號讀取員工編號輸入員工編號實現(xiàn)產(chǎn)品數(shù)量累加調(diào)用刪除函數(shù)輸出員工工作量/系統(tǒng)菜單3詳細(xì)設(shè)計整個系統(tǒng)除了主函數(shù)外,另外還有多個函數(shù),實現(xiàn)五大功能:輸入功能、顯示功能、排序功 能、累加功能、插入功能、。各個函數(shù)的詳細(xì)設(shè)計說明分別如下:1.主函數(shù)main()利用無限次循環(huán)for(;)和swithch()實現(xiàn)各函數(shù)的調(diào)用,系統(tǒng)根據(jù)輸入的數(shù)字選項來調(diào)用相應(yīng)的函數(shù)。2?初始化函數(shù) STUDENT *in it()這是一個無參函數(shù),里面只有一個語句,它的作用是使鏈表初始化,使hea

8、d的值為NULL。比如:沒有這個函數(shù)的話,在你沒有輸入任何數(shù)據(jù)的情況下,去執(zhí)行顯示功能的時候會顯示一些亂碼!3 .輸入t己錄函數(shù) STUDENT *create()這是一個無參函數(shù),用來執(zhí)行職工工作量的輸入,當(dāng)職工為0時停止輸入,函數(shù)結(jié)束后,帶同一個指向鏈表頭的指針 head。算法:先聲明一個首節(jié)點 head ,弁將head-next設(shè)為NULL。每輸入一個數(shù)據(jù)就聲明一個 新節(jié)點 p,把p->next設(shè)為NULL,弁且鏈接到之前列表的尾端。N-S流程head=NULLfor(;)指針pl指向新開辟的單元指針pl是否為空八iTE 否輸出內(nèi)存 溢出輸入工號 p1->nump1->

9、num是否為0八否停止輸 入返回 菜單輸入工作量11p1->productscount=atoi(temp) ; p1-> next=NULL;4 .插入函數(shù) TS *lnsertIntoLink(empnumber,productscount)這是一個有參函數(shù),形參有兩個,一個是“鏈表頭的指針”,一個是“待插入指針”,插入后會重新進(jìn)行排序,弁返回。 算法:先將職工工作量進(jìn)行排序,再插入一個新的結(jié)點。先用指針變量p2指向待插入的結(jié)點,p3指向第一個結(jié)點。如果 p2->p1<p3->p1 ,則待插入的結(jié)點不應(yīng)插在p3所指的結(jié)點之 前。此時將p3后移,弁使p2指向剛才

10、pl所指的結(jié)點。重復(fù)以上的步驟,直到p24P1>=p3->p1為止。這時將p0指向的結(jié)點插到pl所指結(jié)點之前。如果插入位置為第一個結(jié)點之前,貝U將 p2賦給head ,將p3賦給p2->next。如果要插到表尾之后,應(yīng)將 p2賦給p3->next , NULL賦給 p2->next 。最后再調(diào)用排序的函數(shù),重新排序?N-S流程圖如下:P1=head, p2=new原來的鏈表是空表是一否將p0所指的 結(jié)點作為唯 一結(jié)點當(dāng)p2->p1<p3->p1 ,以及p1所指向的不是表尾結(jié)占八、p2手曰問 p1 RJil p1 向后侈-,結(jié)刀、L->p1&

11、gt;=p3->p1是?否指向頭結(jié)點p24n ext=p1 p1-> next=NULL (插至U表尾之后)head=p2 p2 ->next=p1 (插到表頭之前)p1- >n ext=p2p2->n ext=p1(插到表中間)n=n+1 ;(結(jié)點加 1) head=sort (hear);(重新排序)4調(diào)試分析結(jié)果反(1)剛開始沒有那個初始化函數(shù),程序運行后,沒有輸入任何數(shù)據(jù)就試得去執(zhí)行顯示功能,顯示的是一些亂碼!加入初始化函數(shù)后,這種現(xiàn)象也隨之消失。(2)剛開始執(zhí)行輸入函數(shù),輸入多個職工的工作量,輸完后執(zhí)行,職工的工作量是按工號的順序顯示的,試著在其中增加一

12、些語句,希望能把工號按正常順序顯示in put employee nu mber and the counts of productsexit: Double times 0 !112the head is n ull,so,the lin klist head in serted success!retur n the head of the lin klist!in put employee nu mber and the counts of productsexit: Double times ENTER216the head is NOT n ull,so,the lin klist

13、head in serted success!retur n the head of the lin klist!in put employee nu mber and the counts of productsexit: Double times ENTER3 11 the end of linklist inserted success! return the head of the linklist!input employee number and the counts of products exit: Double times ENTER 00Pleas Make you cho

14、ice1. Change Employee Information2. Delet Employee Number3. Print the linklist0.Exityour choice:3output the result:orderporductscountempnumber11621165212121243113496Pleas Make you choice1. Change Employee Information2. Delet Employee Number3. Print the linklist0.Exit your choice:1Please Input you Em

15、ployee Number And Products Count you are to change! the employee Number :5Searching for the number,Please wait Find it!print the nod of temp: temp.empnumber= 5print the nod of temp: ductscount= 16print the nod of temp: temp.empnumber= 5print the nod of temp: ductscount= 16print the n

16、od of temp: t2.empnumber= 5 printthe nod of temp: ductscount= 16 befor Delete the temp node output the result:order porductscount empnumber11621165212121243113496delets employee Number :5after delete the temp node .output the result:order12234porductscount161212119empnumber21436Would you like

17、to input more products count? if not,please type 0 your Input: 16Would you like to input more products count? if not,please type 0 your Input: 14Would you like to input more products count? if not,please type 0 your Input: 20Would you like to input more products count? if not,please type 0 your Inpu

18、t: 0the head is NOT null,so,the linklist head inserted success! return the head of the linklist!empnumber521436output the result:orderporductscount21631231241159Pleas Make you choice1. Change Employee Information2. Delet Employee Number3. Print the linklist0.Exityour choice:2input the Employee Numbe

19、r you wanna delete:3 delets employee Number :3Pleas Make you choice1. Change Employee Information2. Delet Employee Number3. Print the linklist0.Exityour choice:3output the result:orderporductscountempnumber1 6652 1623 12131244 96Pleas Make you choice 1.Change Employee Information2. Delet Employee Nu

20、mber3. Print the linklist0.Exit your choice:05 總結(jié)經(jīng)過幾天的C 語言課程設(shè)計,感覺自己收獲不少!首先是:鏈表本來上課是沒有上的,但這個課程設(shè)計里面主要都是用鏈表,因為要達(dá)到這樣的功能, 使用鏈表相當(dāng)方便,但不容易理解,所以在這方面我很了很多的時間看課本和參考課外書,使 C 語言的知識強(qiáng)化了不少。其次, 在做課程設(shè)計的過程中,發(fā)現(xiàn)了平時很多沒有注意到的問題,例如:返回值函數(shù)和不返回值函數(shù)兩者在主函數(shù)中的調(diào)用是不同的, 更重要的是,這次課程設(shè)計雖然花了我不少時間,但正是這些時間,讓我見識到了C 語言 的重要性。由于這是第一次進(jìn)行設(shè)計,寫文檔,難免會寫

21、得不好!6 .附錄代碼設(shè)計.#include <stdio.h>#include <stdlib.h>#include <string.h>#include <malloc.h>#include <string.h>typedef struct STRUCT/* 定義結(jié)構(gòu)體*/int empnumber;/* 員工編號*/int productscount; /* 產(chǎn)品數(shù)量*/struct STRUCT *next;/* 指向下一個節(jié)點的指針*/TS;/* 結(jié)構(gòu)體的別名*/ main()TS *CreateLink(TS*); /*

22、聲明創(chuàng)建鏈表的函數(shù)*/TS *InsertIntoLink(); /* 聲明插入鏈表的函數(shù)*/TS *DeletFromLink(); /* 聲明刪除函數(shù)*/TS *Search();void print();/* 聲明打印鏈表的函數(shù)*/TS *head;TS *temp;TS *t2;char s100;int empnumber=0;int productscount=0;int n;head=NULL;head=CreateLink(head); /* 先創(chuàng)建空鏈表*/temp=(TS*)malloc(sizeof(TS);t2=(TS*)malloc(sizeof(TS);while(

23、1) /* 一個可控制的循環(huán)*/LOOP: printf("ntPleas Make you choicen");/* 系統(tǒng)菜單*/printf("1.Change Employee Informationn");/* 改變員工信息*/printf("2.Delet Employee Numbern");/* 刪除員工編號*/printf("3.Print the linklistn");printf("0.Exitn");/* 退出系統(tǒng)*/printf("your choice:&q

24、uot;);gets(s);if(strcmp(s,"1")!=0&&strcmp(s,"2")!=0&&strcmp(s,"3")!=0)return;/* 如果不是1 或者 2 選 項,就退出系統(tǒng)*/if(strcmp(s,"1")=0) /* 選擇選項1 ,進(jìn)行改變員工信息操作*/printf("nPlease Input you Employee Number And Products Count you are to change!ntheemployee Num

25、ber :");gets(s);empnumber=atoi(s); /* 輸入員工編號*/ printf("nSearching for the number,Please wait n");temp=Search(head,empnumber);printf("nprint the nod of temp: temp.empnumber= %d",temp->empnumber); printf("nprintthe nod of temp: ductscount= %d",temp->pro

26、ductscount);/* */ if(temp=NULL)goto LOOP;else t2->empnumber=temp->empnumber; t2->productscount=temp->productscount;/* memcpy(t2,temp,sizeof(TS);*/ printf("nprint the nod of temp:temp.empnumber= %d",temp->empnumber); printf("nprint the nod of temp: ductscount= %d

27、",temp->productscount);printf("nprint the nod of temp: t2.empnumber= %d",t2->empnumber);printf("nprint the nod of temp: ductscount= %d",t2->productscount);/*/t2->next=NULL; printf("nbefor Delete the temp node n");print(head);head=DeletFromLink(hea

28、d,t2->empnumber); printf("nafter delete the temp node n");print(head);productscount+=t2->productscount; while(1) /* 改循環(huán)實現(xiàn)產(chǎn)品數(shù)量累加計算*/ printf("Would you like to input more products count? if not,please type 0nyour Input: ");gets(s); if(strcmp(s,"0")!=0) productscount

29、+=atoi(s);/* 累加操作*/else break; /* 停止累加*/ t2->productscount=productscount;head=InsertIntoLink(head,t2->empnumber,t2->productscount);/* 把員 工編號和產(chǎn)品數(shù)量插入到鏈表中*/print(head); /* 打印改鏈表*/ else if(strcmp(s,"2")=0)printf("input the Employee Number you wanna delete:"); /* 選擇選項2,進(jìn)行了刪除員

30、工信息操作*/gets(s);empnumber=atoi(s); /* 讀取員工編號*/*Search(head,empnumber); */ head=DeletFromLink(head,empnumber); /* 調(diào)用刪除函數(shù) */ else print(head);TS *CreateLink(TS *head) /* 創(chuàng)建鏈表函數(shù)*/char temp100;TS *p1;p1=(TS*)malloc(sizeof(TS); /* 為一個鏈表節(jié)點分配存儲空間*/printf(" input employee number and the counts of produc

31、tsn"); printf("exit: Double times 0 !n");/*兩次輸入0,表示退出*/gets(temp);p1->empnumber=atoi(temp); /* 輸入員工編號*/gets(temp); p1->productscount=atoi(temp);/* 輸入產(chǎn)品數(shù)量*/ p1->next=NULL; /* 鏈表節(jié)點的尾指針賦值為NULL*/while(p1->empnumber>0)/* 當(dāng)輸入的員工編號不為0*/*if(head=NULL)head=p1; 第一次插入,插在表頭*/head=I

32、nsertIntoLink(head,p1->empnumber,p1->productscount);/* 調(diào)用插入函數(shù),進(jìn)行節(jié)點插入 */p1=(TS*)malloc(sizeof(TS); /* 為 p1 節(jié)點分配存儲空間*/printf(" input employee number and the counts of productsn"); printf("exit: Double timesENTERn");gets(temp);p1->empnumber=atoi(temp); /* 為 p1 的成員變量empnumbe

33、r 賦值 */ gets(temp);p1->productscount=atoi(temp); /* 為 p1 的成員變量賦值*/ p1->next=NULL;return head; /* 返回首指針*/TS *InsertIntoLink(TS* head,int empnumber,int productscount) /* 插入函數(shù),有序插入*/TS *p1,*p2,*p3;p1=(TS*)malloc(sizeof(TS); /* 新建一個節(jié)點*/ p1->empnumber=empnumber; /* 為節(jié)點賦值*/p1->productscount=pr

34、oductscount;p2=head; /*p2 指向首節(jié)點*/if(head=NULL) /* 首節(jié)點為空*/ head=p1;p1->next=NULL;/* 新節(jié)點插入在表頭*/ printf("the head is null,so,the linklist headinserted success!n");else /* 首節(jié)點不為空*/while(productscount<p2->productscount&&p2->next!=NULL)*/* 插入產(chǎn)品數(shù)量少于當(dāng)前節(jié)點的產(chǎn)品數(shù)量p3=p2;p2=p2->nex

35、t; /* 指針下移,繼續(xù)搜索*/ if(productscount>=p2->productscount)if(productscount=p2->productscount)while(productscount=p2->productscount&&empnumber>p2->empnumber&&p2->next!=NULL)/* 員工編號從小到大排序,如果要插入的員工編號比當(dāng)前節(jié)點大,就繼續(xù)往下搜索*/p3=p2;p2=p2->next;if(head=p2) /* 插在表頭*/head=p1;p1-&g

36、t;next=p2;printf("the head is NOT null,so,the linklist head inserted success!n"); else /* 插在表中間*/p3->next=p1;p1->next=p2;printf("the midle of linklist inserted success!n"); else /* 插在表尾*/p2->next=p1;p1->next=NULL;printf("the end of linklist inserted success!n");printf("return the head of the linklist!n");return(head);void print(TS *head) /* 打印函數(shù)*/TS *temp,*p1;int i=1;temp=head;/* 頭指針賦值給temp,temp 指向鏈表頭*/printf("n output

溫馨提示

  • 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)方式做保護(hù)處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

評論

0/150

提交評論