數(shù)據(jù)結(jié)構(gòu)課程設(shè)計(jì)-字符型界面的設(shè)計(jì)與實(shí)現(xiàn).docx_第1頁
數(shù)據(jù)結(jié)構(gòu)課程設(shè)計(jì)-字符型界面的設(shè)計(jì)與實(shí)現(xiàn).docx_第2頁
數(shù)據(jù)結(jié)構(gòu)課程設(shè)計(jì)-字符型界面的設(shè)計(jì)與實(shí)現(xiàn).docx_第3頁
數(shù)據(jù)結(jié)構(gòu)課程設(shè)計(jì)-字符型界面的設(shè)計(jì)與實(shí)現(xiàn).docx_第4頁
數(shù)據(jù)結(jié)構(gòu)課程設(shè)計(jì)-字符型界面的設(shè)計(jì)與實(shí)現(xiàn).docx_第5頁
已閱讀5頁,還剩7頁未讀 繼續(xù)免費(fèi)閱讀

下載本文檔

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

文檔簡介

成績評(píng)定教師簽名嘉應(yīng)學(xué)院 計(jì)算機(jī)學(xué)院實(shí)驗(yàn)報(bào)告課程名稱:數(shù)據(jù)結(jié)構(gòu)課程設(shè)計(jì)開課學(xué)期:2017-2018學(xué)年第2學(xué)期班 級(jí):指導(dǎo)老師:實(shí)驗(yàn)題目:字符界面的設(shè)計(jì)與實(shí)現(xiàn)學(xué) 號(hào):姓 名:上機(jī)時(shí)間:1. 界面背景顏色設(shè)置 界面背景顏色設(shè)置需要調(diào)用system(color)函數(shù),并且包含頭文件stdlib.h。其中,顏色屬性有兩十六進(jìn)制數(shù)字指定,第一個(gè)為背景色,第二個(gè)則為前景色。函數(shù)system(“color 1f”)中,1代表背景為藍(lán)色,f代表前景字體為亮白色。表1-10是前景色和背景色取值含義的對照表,顏色的取值有16種,從0到F。2. 界面背景大小設(shè)置 界面背景顏色設(shè)置需要調(diào)用system(mode con)函數(shù),并且包含頭文件stdlib.h。例如,要設(shè)置背景大小為: 長35行,寬78列的矩形。調(diào)用格式為:system(“mode con: cols=78 lines=35”);3. 字符菜單設(shè)計(jì),源代碼:#include#includevoid Red()printf(Redn); system(pause);system(color 4f);void Blue()printf(Bluen); system(pause);system(color 9f);void Green()printf(Greenn); system(pause);system(color 2f);void Yellow()printf(Yellown); system(pause);system(color 6f);void Gray()printf(Grayn); system(pause);system(color 8f);void main()system(color 1f);/設(shè)置界面為白字藍(lán)底system(mode con: cols=78 lines=35); /設(shè)置界面大小char c;do/循環(huán)語句保證主菜單始終出現(xiàn)在界面system(cls);printf(t 1.Redn);printf(t 2.Greenn);printf(t 3.bluen);printf(t 4.Yellown);printf(t 5.Grayn);printf(t 6.Goodbyen);printf(Please Input choose(1-6): );scanf(%s,&c);switch(c)/實(shí)現(xiàn)菜單功能的選擇case 1: Red(); break;case 2: Green(); break;case 3: Blue(); break;case 4: Yellow(); break;case 5: Gray(); break;case 6: printf(Goodbye!n); exit(0);default: printf(Error,please input again!n); break;while(c!=6);4.測試運(yùn)行界面主菜單輸入選擇1并回車后,運(yùn)行結(jié)果如圖輸入選擇2并回車后,運(yùn)行結(jié)果如圖輸入選擇3并回車后,運(yùn)行結(jié)果如圖輸入選擇4并回車后,運(yùn)行結(jié)果如圖輸入選擇5并回車后,運(yùn)行結(jié)果如圖輸入選擇6并回車,退出應(yīng)用程序??偨Y(jié):應(yīng)用程序的界面是與用戶交流最直接的渠道。使用方便,布局合理,顏色和諧,界面文字簡介規(guī)范。使用戶更能接受并使用該應(yīng)用程序。完整代碼如下:#include#include#include#define N 6 /航班數(shù)/航班信息typedef struct flight char flight_number10; /航班號(hào) char start_address10; /起飛站 char arrived_address10; /終點(diǎn)站 char work_date10; /班期 char start_time6; /起飛時(shí)間 char arrived_time6; /到達(dá)時(shí)間 char FlightType4; /機(jī)型 int fare; /票價(jià) DataType;struct flight FlightN;/-按航班號(hào)進(jìn)行基數(shù)排序-typedef char KeyType;#define D 7 / D為排序碼的最大位數(shù) #define R a / R為基數(shù),這里為小于字母a代表的整型值 struct Node; /單鏈表結(jié)點(diǎn)類型 typedef struct Node RadixNode;struct Node KeyType keyD; /關(guān)鍵字 DataType info; /數(shù)據(jù)信息 RadixNode *next;typedef RadixNode * RadixList;typedef struct QueueNode RadixNode *f; /對列的頭指針 RadixNode *e; /對列的尾指針 Queue;Queue queueR;/用隊(duì)列表示桶void radixSort(RadixList * plist, int d, int r) int i,j,k; RadixNode *p, *head; head=(*plist)-next; for(j=d-1; j=0; j-) /進(jìn)行d次分配和收集 p=head; for(i=0; ikeyj; /按排序碼的第j個(gè)分量進(jìn)行分配 if(queuek.f=NULL) queuek.f=p; / 若第k個(gè)堆為空,則當(dāng)前記錄為隊(duì)頭 else (queuek.e)-next=p; / 否則當(dāng)前記錄鏈接到第k隊(duì)的隊(duì)尾 queuek.e=p; p=p-next; i=0; while(queuei.f=NULL) i+; / 從r個(gè)隊(duì)列中找出第一個(gè)非空的隊(duì)列 p=queuei.e; head=queuei.f; /head為收集鏈表的頭指針 for(i+; inext=queuei.f; p=queuei.e; / 收集非空隊(duì)列 p-next=NULL; (*plist)-next=head;/初始化航班信息struct Node elementN+1= , , , , , , , ,0,NULL,/表頭 CA1544,CA1544,合肥,北京,1245 ,10:55,12:40,733,960,NULL, MU5341,MU5341,上海,廣州,每日 ,14:20,16:15,M90,1280,NULL, CZ3869,CZ3869,重慶,深圳,246 ,08:55,10:35,733,1010,NULL, MU3682,MU3682,桂林,南京,23467,20:50,22:15,M90,1380,NULL, HU1836,HU1836,上海,北京,每日 ,09:40,11:20,738,1250,NULL, CZ3528,CZ3528,成都,廈門,13457,15:10,16:50,CRJ,1060,NULL,; /-信 息 顯 示-/按表的格式輸出某個(gè)航班信息/顯示頭部信息void Cout_info1() cout *nendl;cout * 歡 迎 您 使 用 *nendl; cout * 航 班 信 息 表 *nendl; cout *nendl; cout 航班號(hào) 起飛時(shí)間 到達(dá)時(shí)間 起飛站 終點(diǎn)站 班期 機(jī)型 票價(jià)nendl; /顯示主體信息void Cout_info2_1(Node p)/方式一 cout info.flight_number; cout info.start_time; cout info.arrived_time; cout info.start_address; cout info.arrived_address; cout info.work_date; cout info.FlightType; cout info.fare元endl;void Cout_info2_2(flight F,int i)/方式二 cout Fi.flight_number; cout Fi.start_time; cout Fi.arrived_time; cout Fi.start_address; cout Fi.arrived_address; cout Fi.work_date; cout Fi.FlightType; cout Fi.fare元next; while(p!=NULL) Cout_info2_1(p); p=p-next; coutendl;void output_ALL_info2(flight F) /方式二 Cout_info1(); for(int i=0;iN;i+) Cout_info2_2(F,i); coutnext; int i; for(i=0;iinfo.flight_number); strcpy(Fi.start_time,p-info.start_time); strcpy(Fi.arrived_time,p-info.arrived_time); strcpy(Fi.start_address,p-info.start_address); strcpy(Fi.arrived_address,p-info.arrived_address); strcpy(Fi.work_date,p-info.work_date); strcpy(Fi.FlightType,p-info.FlightType); Fi.fare=p-info.fare; p=p-next; /-服 務(wù) 菜 單-void F_By_Time(flight F,int);void F_By_Address(flight F,int);void F_By_fare(flight F);void F_By_FN(flight F); /主菜單void mainmenu() char ch; int y; cout 主菜單nendl; cout =nendl; cout Please choose: (input the number)(輸入查詢/排序命令)nendl; cout 0. show the mainmenu (顯示主菜單)nendl; cout 1. Find by flight number(按航班號(hào)查詢)nendl; cout 2. Find by start time(按起飛時(shí)間查詢)nendl; cout 3. Find by arrived time(按到達(dá)時(shí)間查詢)nendl; cout 4. Find by start address(按起飛地點(diǎn)查詢)nendl; cout 5. Find by arrived address(按目的地點(diǎn)查詢)nendl; cout 6. Find by the fare(按票價(jià)范圍查詢)nendl; cout -其他鍵退出endl; cout =nendl; while(1) couty; switch(y) case 0: mainmenu();break; case 1:F_By_FN(Flight);break; case 2:F_By_Time(Flight,1);break; case 3:F_By_Time(Flight,2);break; case 4:F_By_Address(Flight,1);break; case 5:F_By_Address(Flight,2);break; case 6:F_By_fare(Flight);break; default :cout 謝謝惠顧! endl;break; coutch; if(ch=Y|ch=y) break; /-查 詢 系 統(tǒng)-/通過航班號(hào)實(shí)現(xiàn)二分查找法查找void F_By_FN(flight F) int low=0,high=N,mid; char Num10; coutNum; Cout_info1();/顯示頭部信息 while(low=high) mid=(low+high)/2; if(strcmp(Num,Fmid.flight_number)=0) Cout_info2_2(F,mid);break; else if(strcmp(Num,Fmid.flight_number)0) high=mid-1; else low=mid+1; cout *對不起,沒有您要查找的航班號(hào)* endl;/通過起飛/到達(dá)時(shí)間查詢void F_By_Time(flight F,int Time) int i; char T6; coutT; Cout_info1();/顯示頭部信息 for(i=0;iN;i+) if(Time=1) /按起飛時(shí)間查詢 if(strcmp(T,Fi.start_time)=0) Cout_info2_2(F,i); if(Time=2) /按抵達(dá)時(shí)間查詢 if(strcmp(T,Fi.arrived_time)=0) Cout_info2_2(F,i); cout *對不起,該時(shí)間沒有航班* endl;/通過站點(diǎn)查詢void F_By_Address(flight F,int AD) char str10; coutstr

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(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ǔ)空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

最新文檔

評(píng)論

0/150

提交評(píng)論