// #include
\n\t 請(qǐng)輸入所列出的選項(xiàng)\n\n 3 秒后刷新...Please Weit! Thanks\n"); fflush(stdin);sleep(3000); system("cls"); goto Loop;}else{ switch(k){case 1:hotel_execute();break; case 2:hotel_select();break; case 3:hotel_total();break; case 4:hotel_outhotel();break; case 5:outsystem();return; default:printf("\n\t 系統(tǒng)出錯(cuò)!請(qǐng)聯(lián)系管理員!\n");//怕出現(xiàn) BUG return;}}fflush(stdin); //清空緩存}}//入住登記void hotel_execute(){int x,y,z;printf("請(qǐng)輸入你要住本酒店多少層樓的住房?【1-5】"); fflush(stdin);L:scanf("%d",&x); p=x;if(x>5){printf("不好意思本店沒(méi)有該層樓房\n 請(qǐng)重新選擇:"); goto L;}printf("請(qǐng)輸入你要住第%d 層的幾號(hào)房間?【1-5】",x); fflush(stdin);LP:scanf("%d",&y); if(y>5){printf("不好意思該層樓并無(wú)該房間。
\n 請(qǐng)重新選擇:"); goto LP;//無(wú)條件的回去 GOTO 語(yǔ)句}if(x>2){//二層以上則 100 元一天printf("\n 提示:該房是貴賓套房,100 元一天\n");}else{printf("\n 提示:該房是標(biāo)準(zhǔn)套房,50 元一天\n");}if(room[x-1][y-1]==0)//判斷該房已經(jīng)入住{room[x-1][y-1]=1;printf("\n 謝謝您的光臨,您已經(jīng)成功登記\n 您的信息如下:\n 入住房間:%d-%d\n",x,y); start=clock();}else{printf("警告:該房已經(jīng)有人入住...請(qǐng)換房入住哈\n");}}//查詢住房信息void hotel_select(){int x,y,z;system("cls");//清空內(nèi)容//以下沒(méi)什么重要的就是控制輸出格式printf("賓館入住情況如下:");printf("\n|-------|--------|--------|--------|--------| |\n");printf("| |"); for(x=1;x<=5;x++){printf("房間號(hào) |");}printf("\n"); for(x=0;x<5;x++){if(x==0){printf("|-------|--------|--------|--------|--------|--------|\n|第%d 層 |",x+1);}else{printf("\n|-------|--------|--------|--------|--------|--------|\n|第%d 層 |",x+1);}for(y=0;y<5;y++)if(room[x][y]==0){printf("空%d-%d |",x+1,y+1);}else{printf("住%d-%d |",x+1,y+1);}if(y+1==5){if(x+1==1||x+1==2)printf(" 該層標(biāo)間均 50 元"); elseprintf(" 該層標(biāo)間均 100 元");}}}printf("\n|-------|--------|--------|--------|--------| |\n");printf("\n 住房信息:\n"); for(x=0,z=0;x<5;x++){for(y=0;y<5;y++){if(room[x][y]!=0){z++;printf("\t%d-%d 有人入住\n",x+1,y+1);}}}if(z==0){printf("\t 現(xiàn)無(wú)人入住本酒店...\n");}}//結(jié)賬void hotel_outhotel(){int x=0,y=0;printf("請(qǐng)輸入您要結(jié)賬退房的樓層編號(hào)?"); scanf("%d",&x);printf("請(qǐng)輸入該樓層退房的房間編號(hào)?"); scanf("%d",&y);if(room[x-1][y-1]==1){room[x-1][y-1]=0;printf("\n\t 房間%d-%d 退房成功,再會(huì)。
\n",x,y);}else{printf("\n\t 房間%d-%d 退房失敗\n\t\t 原因:未入住,是空房,不需要退...再會(huì)\n",x,y);}}//查看價(jià)錢(qián)void hotel_total(){//在 c 語(yǔ)言中有專門(mén)處理系統(tǒng)時(shí)間,程序計(jì)時(shí)等等功能的庫(kù),即 time.h//在 time.h 中函數(shù) clock_t clock( void )可以完成計(jì)時(shí)功能//這個(gè)函數(shù)返回從“開(kāi)啟這個(gè)程序進(jìn)程”到“程序中調(diào)用 clock()函數(shù)”時(shí)之間的 CPU 時(shí)鐘計(jì)時(shí)單元(clock tick)數(shù),//在 MSDN 中稱之為掛鐘時(shí)間(wal-clock)//其中 clock_t 是用來(lái)保存時(shí)間的數(shù)據(jù)類(lèi)型,在 time.h 文件中,//我們可以找到對(duì)它的定義: #ifndef _CLOCK_T_DEFINED typedef long clock_t;//#define _CLOCK_T_DEFINED #endif 很明顯,clock_t 是一個(gè)長(zhǎng)整形數(shù)在 time.h 文件中,還定義了一個(gè)常量 CLOCKS_PER_SEC,//它用來(lái)表示一秒鐘會(huì)有多少個(gè)時(shí)鐘計(jì)時(shí)單元,//其定義如下: #define CLOCKS_PER_SEC ((clock_t)1000) 可以看到每過(guò)千分之一秒(1 毫秒),//調(diào)用 clock()函數(shù)返回的值就加 1。
clock_t finish=clock();double duration = (double)(finish - start) / CLOCKS_PER_SEC; double day=duration/60/60/24;//這里是將秒換成天double total=0;printf( "您住了%f 秒鐘...\n",duration);//system("pause");按任意鍵繼續(xù)...if(p>2){ total=day*100; if(day==0){ total=100;}printf("\n 我們旅店是按包天計(jì)費(fèi)的\n 若按小時(shí),您需要付%f 元,但是現(xiàn)在你要付 100元(黑店哈哈)\n",total);//這種計(jì)費(fèi)方式比較現(xiàn)實(shí)符合實(shí)際}else{ total=day*50;if(day==0){total=50;}printf("\n 我們旅店是按包天計(jì)費(fèi)的\n 若按小時(shí),您需要付%f 元,但是現(xiàn)在你要付 50元(黑店哈哈)\n",total);}}//退出void outsystem(){char message[] = "\n 酒店登記計(jì)費(fèi)系統(tǒng).打造酒店中的名牌 ";for(i=0;i }printf("\n\n");}//1.本系統(tǒng)未用到文件//2.本系統(tǒng)采用函數(shù)//3.本系統(tǒng)用例比較小//4.本系統(tǒng)有良好的界面,舒適的變成思路和整齊的代碼//5.本程序引用一個(gè)時(shí)間進(jìn)程另外控制時(shí)間//6.感謝所有關(guān)心我和我關(guān)心的人//7.再會(huì)At the end, Xiao Bian gives you a passage. Minand once said, "people who learn to learn are very happy people.". In every wonderful life, learning is an eternal theme. As a professional clerical and teaching position, I understand the importance of continuous learning, "life is diligent, nothing can be gained", only continuous learning can achieve better self. Only by constantly learning and mastering the latest relevant knowledge, can employees from all walks of life keep up with the pace of enterprise development and innovate to meet the needs of the market. This document is also edited by my studio professionals, there may be errors in the document, if there are errors, please correct, thank 。




![[精編]吳教人[]13號(hào)](/Images/s.gif)







