




版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡(jiǎn)介
1、第一題:1,【實(shí)驗(yàn)題目及要求】問題描述設(shè)計(jì)一個(gè)程序,記錄并管理日程計(jì)劃。基本要求(1)日程計(jì)劃信息包括日程計(jì)劃ID號(hào),日程計(jì)劃開始日期和時(shí)間,日程計(jì)劃結(jié)束日期和時(shí)間,日程計(jì)劃名,日程計(jì)劃參與人員,日程計(jì)劃地點(diǎn),日程計(jì)劃提醒日期和時(shí)間。(2)采用雙向循環(huán)鏈表表示日程計(jì)劃信息。采用三個(gè)雙向循環(huán)鏈表:第一個(gè)雙向循環(huán)鏈表表示未開始的日程計(jì)劃信息,按照日程計(jì)劃開始日期和時(shí)間先后排序;第二個(gè)雙向循環(huán)鏈表表示正在進(jìn)行的日程計(jì)劃信息(可以多項(xiàng)計(jì)劃同時(shí)進(jìn)行),按照日程計(jì)劃開始日期和時(shí)間先后排序;第三個(gè)雙向循環(huán)鏈表表示已過期的日程計(jì)劃信息,按照日程計(jì)劃開始的日期和時(shí)間倒序排序。(3)日程計(jì)劃信息采用文件方式輸入。
2、日程計(jì)劃信息信息示例如下,每條信息一行:日程計(jì)劃ID號(hào)開始日期開始時(shí)間結(jié)束日期結(jié)束時(shí)間計(jì)劃名20141011001;2014-10-11;8:00:00;2014-10-11;10:00:00;數(shù)據(jù)結(jié)構(gòu)上課;張三;6202;2014-10-11;7:40:00(4)要求模擬數(shù)據(jù)中日程計(jì)劃信息至少30條以上。(5)實(shí)現(xiàn)以下功能:a.輸入新的計(jì)劃;b.根據(jù)當(dāng)前時(shí)間查詢未開始的計(jì)劃,包括當(dāng)天未開始的計(jì)劃、本周或本月未開始的計(jì)劃;c.查詢并輸出已結(jié)束的計(jì)劃;d.查詢正在進(jìn)行的計(jì)劃;e.根據(jù)當(dāng)前時(shí)間,輸出正提醒即將開始的計(jì)劃。(6)可在此要求基礎(chǔ)上進(jìn)行功能擴(kuò)展,比如周期性重復(fù)計(jì)劃的設(shè)置和提醒等。2,【源
3、代碼(C語(yǔ)言)#include<stdio.h>#include<stdlib.h>#include<time.h>#include<string.h>#defineNAMESIZE20/宏定義名字最大長(zhǎng)度#definePLACESIZE20/地名最大長(zhǎng)度#defineOK1#defineERROR0typedefstructPeoplecharpeoNameNAMESIZE;structPeople*next;People;/定義日程計(jì)劃參與人員結(jié)構(gòu)體typedefstructTeamintpeoNumber;/參與人數(shù)People*peo;/
4、參與人員的具體姓名Team;/定義日程計(jì)劃結(jié)構(gòu)體(核心)typedefstructPlancharID12;/日程IDtime_tstrartTime,finishTime,warnTime;/開始時(shí)間和結(jié)束時(shí)間charnameNAMESIZE;/日程名稱Teampeople;/參與人員charplacePLACESIZE;/地點(diǎn)structPlan*pre,*next;Plan;/定義個(gè)人日程結(jié)構(gòu)體typedefstructcharnameNAMESIZE;/個(gè)人姓名time_tfirstTime;intprePlanNum,presentPlanNum,postPlanNum;/開啟日程管
5、理的時(shí)間Plan*prePlan,*presentPlan,*postPlan;PlanManege;ntInitPlanManege(PlanManege*);初始化日程管理ntInputNewPlan(PlanManege*);/添加新的計(jì)劃ntSearchPrePlan(PlanManege*);/查詢尚未開始的計(jì)劃ntSearchPostPlan(PlanManege*);/查詢已經(jīng)結(jié)束的計(jì)劃ntSearchPresent(PlanManege*);/查詢正在進(jìn)行的計(jì)劃ntSearchWarnPlan(PlanManege*);/查詢即將開始的計(jì)劃ntInputFileStr(FILE
6、*,char*);/輸入文件的字符串ntInputSevalFileStr(FILE*,Team*);/輸入多個(gè)文件字符串ntInputFileTime(FILE*,time_t*);/按格式輸入文件時(shí)間ntPlanSort(Plan*,PlanManege*);/計(jì)劃排序ntInsertPlan(Plan*,Plan*);/插入計(jì)劃ntInputScreenTime(time_t*);/按格式讀入時(shí)間/讀入多個(gè)字符串ntInputTeamName(People*);ntPrintPlan(Plan*);/計(jì)劃輸出函數(shù)voidmain()printf(6退出n");printf(*n
7、scanf("%d",&i);switch(i)case 1: InputNewPlan(&me);breakcase 2: SearchPrePlan(&me);breakcase 3: SearchPresentPlan(&me);break;case 4: SearchPostPlan(&me);breakcase 5: SearchWarnPlan(&me);breakcase6:system("PAUSE");exit(0);default:printf("輸入有誤!");br
8、eakntInitPlanManege(PlanManege*me)FILE*fp;time_tpresentTime;Plan*iplan;charch,peoName20;iplan=(Plan*)malloc(sizeof(Plan);me->postPlan=iplan;me->postPlan->next=iplan;me->postPlan->pre=iplan;me->postPlanNum=0;iplan=(Plan*)malloc(sizeof(Plan);me->prePlan=iplan;me->prePlan->ne
9、xt=iplan;me->prePlan->pre=iplan;me->prePlanNum=0;iplan=(Plan*)malloc(sizeof(Plan);me->presentPlan=iplan;me->presentPlan->next=iplan;me->presentPlan->pre=iplan;me->presentPlanNum=0;/打開myplans.txt文件,文件按照格式有一系列寫好的日程計(jì)劃fp=fopen("myplans.txt","r")if(!fp)print
10、f("文件myplans.txt不存在或無(wú)法打開!n");system("PAUSE")printf("已到文件末尾!”);while(!feof(fp)/printf("這是第一次");iplan=(Plan*)malloc(sizeof(Plan)/初始化planiplan->people.peoNumber=0;/把計(jì)劃參與人數(shù)初始化為0iplan->people.peo=NULL;/人名指向?yàn)榭說gets(iplan->ID,12,fp);/printf("%s",iplan-&
11、gt;ID);fgetc(fp);fgetc(fp);InputFileTime(fp,&iplan->strartTime);InputFileTime(fp,&iplan->finishTime);InputFileStr(fp,iplan->name);InputSevalFileStr(fp,&(iplan->people);InputFileStr(fp,iplan->place);InputFileTime(fp,&iplan->warnTime);ch=fgetc(fp);/ch=fgetc(fp);/*pres
12、entTime=time(NULL);if(iplan->strartTime>presentTime)insertPlanList(iplan,me->prePlan);elseif(iplan->finishTime<present)insertPlanList(iplan,me->postPlan);elseinsertPlanList(iplan,me->presentPlan);*/PrintPlan(iplan);if(!PlanSort(iplan,me)printf("here!")returnERROR;/prin
13、tf("存儲(chǔ)完畢");ntInputNewPlan(PlanManege*me)/功能函數(shù),添加一個(gè)計(jì)劃Plan*planp;planp=(Plan*)malloc(sizeof(Plan);printf("請(qǐng)輸入計(jì)劃的ID號(hào)n")scanf("%s",&planp->ID);InputScreenTime(&planp->strartTime);InputScreenTime(&planp->finishTime);printf("請(qǐng)輸入計(jì)劃名稱n")scanf(&quo
14、t;%s",planp->name);printf("請(qǐng)輸入計(jì)劃參與人數(shù)n")scanf("%d",&planp->people.peoNumber);InputTeamName(&planp->people);printf(請(qǐng)輸入計(jì)劃地點(diǎn)nscanf("%s",planp->place);printf("請(qǐng)輸入提醒時(shí)間n(如2010-10-1018:00:00)n")InputScreenTime(&planp->warnTime);if(PlanS
15、ort(planp,me)returnOKelsereturnERRORntSearchPrePlan(PlanManege*me)time_tpresentTime;structtm*timep1,*timep2;Plan*p;presentTime=time(NULL);timep1=gmtime(&presentTime);p=me->prePlan->pre;printf("今天未開始的計(jì)劃有:n")while(p!=me->prePlan)timep2=gmtime(&(p->strartTime);if(timep1-&g
16、t;tm_year=timep2->tm_year&&timep1->tm_mday=imep2->tm_mday&&timep1->tm_mon=timep2->tm_mon)PrintPlan(p);p=p->pre;breakprintf("本月開始的計(jì)劃有:n");while(p!=me->prePlan)timep2=gmtime(&(p->strartTime);if(timep1->tm_mon=timep2->tm_mon)PrintPlan(p);p=p-&
17、gt;pre;breakprintf("其他時(shí)間開始的計(jì)劃有:n");while(p!=me->prePlan)/無(wú)需比較,把剩下的都輸出PrintPlan(p);p=p->pre;returnOK;ntSearchPostPlan(PlanManege*me)inti=1;Plan*p;p=me->postPlan->next;while(p!=me->postPlan)printf("%d'n",i);PrintPlan(p);p=p->next;i+;returnOK;ntSearchPresentPla
18、n(PlanManege*meinti=0;Plan*p;p=me->presentPlan->next;while(p!=me->presentPlan)printf("%d'n",i);PrintPlan(p);p=p->next;ntSearchWarnPlan(PlanManege*me)Plan*planp;time_tpresentTime;presentTime=time(NULL)planp=me->prePlan->next;while(planp!=me->prePlan)if(presentTime&g
19、t;=planp->warnTime)PrintPlan(planp);planp=planp->next;ntInputFileStr(FILE*fp,char*str)charch;inti;ch=fgetc(fp);ch=fgetc(fp);for(i=0;ch!=''i+)if(ch=-1)return0;/printf("%s'n",str);returnOK;ntInputSevalFileStr(FILE*fp,Team*T)inti;charch;People*peop;doch=fgetc(fp);ch=fgetc(fp
20、);if(ch!=-1&&ch!='')peop=(People*)malloc(sizeof(People)for(i=0;ch!=''&&ch!=','i+)peop->peoNamei=ch;ch=fgetc(fp)peop->peoNamei='0/printf("%sn",peop->peoName);/把讀取到的姓名存入?yún)⑴c人員姓名鏈表后/插入第一個(gè)peop->next=T->peo;T->peo=peop;T->peoNumber+
21、;returnERROR;while(ch!='');returnOK;/InputSevalStrntInputFileTime(FILE*fp,timet*time)structtmitime;intyear,month;fscanf(fp,"%d-%d-%d;",&year,&month,&itime.tm_mday);fscanf(fp,"%d:%d:%d;",&itime.tm_hour,&itime.tm_min,&itime.tm_sec);itime.tm_year=year
22、-1900;itime.tm_mon=month-1;itime.tm_isdst=-1;*time=mktime(&itime);/printf("%dn",itime.tm_year);returnOK;/InputTimentPlanSort(Plan*p,PlanManege*pmtime_tpresentTime;presentTime=time(NULL)if(p->strartTime>presentTime)InsertPlan(p,pm->prePlan);elseif(p->finishTime<presentTim
23、e)InsertPlan(p,pm->postPlan);elseInsertPlan(p,pm->presentPlan);returnOK;ntInsertPlan(Plan*p,Plan*pl)/把計(jì)劃按照時(shí)間順序插入計(jì)劃鏈表中Plan*q;q=plwhile(1)if(q->next->strartTime<=p->strartTime|q->next=pl)/插入p->next=q->next;p->pre=q;q->next=pp->next->pre=pntInputScreenTime(timetst
24、ruct tm strTime;int year,month;scanf( "%d-%d-%d" ,&year,&month,&strTime.tm_mday);scanf( "%d:%d:%d” ,&strTime.tm_hour,&strTime.tm_min,&strTime.tm_sec);strTime.tm_year = year - 1900;strTime.tm_mon = month-1;nt PrintPlan( Plan *planp )int i;People *p;printf("
25、 計(jì)劃 ID: %sn" ,planp ->ID);printf(" 開始時(shí)間:s",ctime(&( planp ->strartTime );t)ntInputTeamName(Team*T)T->peo=NULL;printf("請(qǐng)依次輸入每個(gè)參與者姓名,每次以回車鍵結(jié)束n")for(i=0;i<T->peoNumber;i+)peop=(People*)malloc(sizeof(People)scanf("%s",&peop->peoName);peop->next=T->peo;T->peo=peop;returnOK;printf("結(jié)束
溫馨提示
- 1. 本站所有資源如無(wú)特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫(kù)網(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ì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 2025管理人員崗前安全培訓(xùn)考試試題帶答案(培優(yōu)A卷)
- 2024-2025企業(yè)管理人員安全培訓(xùn)考試試題及參考答案【綜合卷】
- 2024-2025廠級(jí)職工安全培訓(xùn)考試試題a4版打印
- 2025建筑設(shè)備租賃合同范本2
- 2025遼寧省家庭居室裝飾裝修合同(LF)
- 2025專業(yè)版汽車租賃合同模板
- 2025資金協(xié)調(diào)項(xiàng)目居間合同
- 2025年石墨化工設(shè)備項(xiàng)目建議書
- 2025貸款服務(wù)合同范本
- 2025年石油產(chǎn)品添加劑:燃料油添加劑項(xiàng)目合作計(jì)劃書
- 大學(xué)英語(yǔ)(二)知到智慧樹章節(jié)測(cè)試課后答案2024年秋海南經(jīng)貿(mào)職業(yè)技術(shù)學(xué)院
- 《汽車專業(yè)英語(yǔ)》2024年課程標(biāo)準(zhǔn)(含課程思政設(shè)計(jì))
- 衛(wèi)生間翻新施工方案
- 小學(xué)數(shù)學(xué)二年級(jí)第二學(xué)期口算計(jì)算共3031道題
- 專題04 水和溶液(解析版)
- 網(wǎng)絡(luò)安全知識(shí)基礎(chǔ)培訓(xùn)課件
- 廣東省云浮市(2024年-2025年小學(xué)六年級(jí)語(yǔ)文)統(tǒng)編版小升初模擬((上下)學(xué)期)試卷及答案
- 宿舍課件教學(xué)課件
- 律師聘用合同證書協(xié)議書
- 2025屆新高考Ⅰ卷高考高三模擬考試語(yǔ)文試卷(二)(含答案解析)
- 電子技術(shù)試卷期末試卷2
評(píng)論
0/150
提交評(píng)論