返回列表 發帖

[作業] 購物系統 (四)

新增 "1-正確無誤 2-重新選購" 的選單
讓使用者在準備結帳時還能反悔, 譬如錢帶不夠.

  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()
  5. {   
  6.     re:
  7.     string name[]={"阿姆姆","艾希","安妮","蓋倫","維爾賽","佛德提克"}; {:3_44:} {:3_41:} :)
  8.     int qty[]={0,0,0,0,0,0};     
  9.     int price[]={1240,136,2584,251,987,654};
  10.     int a,b,sum=0,pay,money,e;
  11.     cout<<"***英雄聯盟***"<<endl;
  12.     cout<<"商品價目表"<<endl;
  13.     cout<<"(1)阿姆姆\t\t1240元"<<endl;
  14.     cout<<"(2)艾希\t\t136元"<<endl;
  15.     cout<<"(3)安妮\t\t2584元"<<endl;
  16.     cout<<"(4)蓋倫\t251元"<<endl;
  17.     cout<<"(5)維爾賽\t\t987元"<<endl;
  18.     cout<<"(6)佛德提克\t\t654元"<<endl;
  19.     cout<<"消費滿5000送提一隻!!(限量  市價1001000元)"<<endl;
  20.     cout<<"選購完時代號都輸入8即可進入結帳頁"<<endl;
  21.     start:
  22.     cout<<"請輸入商品代號:"<<endl;
  23.     cin>>a;
  24.     if(a==8)
  25.     {
  26.          goto end;        
  27.     }
  28.     cout<<"請輸入數量:"<<endl;
  29.     cin>>b;
  30.     if(a>=1 && a<=7 && b>0)
  31.     {   
  32.          sum=sum+price[a-1]*b;
  33.          qty[a-1]=b;
  34.          goto start;        
  35.     }else
  36.     {
  37.          cout<<"輸入錯誤"<<endl;
  38.          goto start;      
  39.     }
  40.     end:
  41.     cout<<endl<<"[購物清單]"<<endl;   
  42.     cout<<"-------------------------------"<<endl;
  43.     for(int i=0;i<=5;i++)
  44.     {   
  45.          if(qty[i]!=0)
  46.          {
  47.                       cout<<name[i]<<"\t"<<price[i]<<"*"<<qty[i]<<"個"<<endl;         
  48.          }                    
  49.     }
  50.     cout<<"-------------------------------"<<endl;     
  51.     cout<<endl<<"\t\t總共"<<sum<<"元!"<<endl;
  52.     cout<<"1正確無誤2重新選購"<<endl;
  53.     cin>>e;
  54.     if(e==1)
  55.     {
  56.          goto good;        
  57.     }else if(e==2)
  58.     {
  59.          goto re;     
  60.     }else
  61.     {
  62.          cout<<"輸入錯誤"<<endl;     
  63.     }
  64.     good:
  65.     if(sum>=5000)
  66.     {
  67.          cout<<"由於消費滿5000,贈送鍍金棺材乙個!!"<<endl;
  68.     }
  69.     cout<<"請輸入付了多少錢: ";
  70.     cin>>pay;
  71.     money=pay-sum;
  72.     if(money==0)
  73.     {
  74.         cout<<"錢剛剛好! 請慢走!"<<endl;
  75.     }
  76.     if(money<0)
  77.     {
  78.         cout<<"錢不夠! 還欠"<<-money<<endl;                  
  79.     }
  80.     if(money>0)
  81.     {
  82.          cout<<"總共需要找客人"<<money<<"元";   
  83.          if(money>=500)
  84.          {
  85.             cout<<"500元鈔票"<<money/500<<"張"<<endl;
  86.             money=money%500;
  87.          }
  88.          if(money>=100)
  89.          {
  90.             cout<<"100元鈔票"<<money/100<<"張"<<endl;
  91.             money=money%100;
  92.          }
  93.          if(money>=50)
  94.          {
  95.             cout<<"50元硬幣"<<money/50<<"枚"<<endl;
  96.             money=money%50;
  97.          }
  98.          if(money>=10)
  99.          {
  100.             cout<<"10元硬幣"<<money/10<<"枚"<<endl;
  101.             money=money%10;
  102.          }
  103.          if(money>=5)
  104.          {
  105.             cout<<"5元硬幣"<<money/5<<"枚"<<endl;
  106.             money=money%5;
  107.          }
  108.          if(money>=1)
  109.          {
  110.             cout<<"1元硬幣"<<money/1<<"枚"<<endl;
  111.             money=money%1;
  112.          }
  113.     }
  114.    
  115.      
  116.     system("pause");   
  117.     return 0;   
  118. }
複製代碼

TOP

本帖最後由 黃柏維 於 2013-7-27 14:19 編輯
  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()
  5. {
  6.   string name[]={"遙控汽車","飛機模型","足球    ","拼圖    ","玩具槍  ","可愛玩偶","籃球    "};
  7.   int price[]={450,550,325,200,660,150,380};
  8.   int qty[]={0,0,0,0,0,0,0};  
  9.   int p,q,pay,money,sum=0,a;
  10.   cout<<"***智能玩具店***"<<endl;
  11.   cout<<"**商品價目表**"<<endl;
  12.   cout<<"(1)遙控汽車\t450元"<<endl;
  13.   cout<<"(2)飛機模型\t550元"<<endl;
  14.   cout<<"(3)足球\t\t325元"<<endl;
  15.   cout<<"(4)拼圖\t\t200元"<<endl;
  16.   cout<<"(5)玩具槍\t660元"<<endl;
  17.   cout<<"(6)可愛玩偶\t150元"<<endl;
  18.   cout<<"(7)籃球\t\t380元"<<endl;
  19.   cout<<"(8)結帳"<<endl;
  20.   cout<<"$請選擇你要的商品$"<<endl;
  21.   start:
  22.   cout<<"請輸入商品代碼: ";
  23.   cin>>p;
  24.   if(p==8)
  25.      goto checkout;
  26.   else
  27.   {
  28.     cout<<"數量: ";
  29.     cin>>q;     
  30.     if(p>=1 && p<=7 && q>0)
  31.     {
  32.         sum=sum+price[p-1]*q;
  33.         qty[p-1]=q;
  34.         goto start;      
  35.     }
  36.     else
  37.     {
  38.         cout<<"輸入錯誤"<<endl;
  39.         goto start;     
  40.     }
  41.   }
  42.      
  43.   checkout:
  44.   cout<<"[購物清單]"<<endl<<endl;
  45.   cout<<"------------------------------"<<endl;
  46.   for(int i=0;i<=6;i++)
  47.   {   
  48.       if(qty[i]!=0)
  49.       cout<<name[i]<<"\t"<<price[i]<<"元 *"<<qty[i]<<"個"<<endl;   
  50.   }
  51.   cout<<"------------------------------"<<endl;
  52.   cout<<"\t\t"<<"總共"<<sum<<"元"<<endl;
  53.   cout<<"1-正確無誤 2-重新選購"<<endl;
  54.   cin>> a;
  55.   if(a==1)
  56.   {
  57.   cout<<"請輸入您付的錢: "<<endl;
  58.   cin>>pay;
  59.   cout<<"找您"<<pay-p<<"元"<<endl;
  60.   }
  61.   else if(a==2)
  62.   {
  63.   goto start;
  64.   }
  65.   else
  66.   {
  67.   cout<<"輸入錯誤"<<endl;
  68.   goto start;
  69.   }
  70.   money=pay-sum;
  71.   if(money>=500)

  72.   {
  73.         cout<<"500元鈔票"<<money/500<<"張"<<endl;
  74.         money=money%500;
  75.   }
  76.   if(money>=100)
  77.   {
  78.         cout<<"100元鈔票"<<money/100<<"張"<<endl;
  79.         money=money%100;
  80.   }
  81.   if(money>=50)
  82.   {
  83.         cout<<"50元硬幣"<<money/50<<"枚"<<endl;
  84.         money=money%50;
  85.   }
  86.   if(money>=10)
  87.   {
  88.         cout<<"10元硬幣"<<money/10<<"枚"<<endl;
  89.         money=money%10;
  90.   }
  91.   system("pause");
  92.   return 0;
  93. }   
複製代碼

TOP

  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()
  5. {
  6.     string name[]={"空氣","石油","行星","水","陽光","黃金","泥土"};
  7.     int qty[]={0,0,0,0,0,0,0};
  8.     int price[]={450,550,1000,200,660,150,380};
  9.     int p,q,sum=0,g,pay,money,chose;
  10.     cout<<"☆★☆21世紀ㄟ店☆★☆"<<endl<<endl;
  11.     cout<<"[商品價目表]"<<endl;
  12.     cout<<"(1)空氣\t450元"<<endl;
  13.     cout<<"(2)石油\t550元"<<endl;
  14.     cout<<"(3)行星\t1000元"<<endl;
  15.     cout<<"(4)水\t200元"<<endl;
  16.     cout<<"(5)陽光\t660元"<<endl;
  17.     cout<<"(6)黃金\t10000元"<<endl;
  18.     cout<<"(7)泥土\t380元"<<endl;
  19.     cout<<"(8)結帳"<<endl<<endl;
  20.     start:
  21.     cout<<"請輸入商品代碼: ";
  22.     cin>>p;
  23.     if(p==8)
  24.     {
  25.         goto checkout;
  26.     }else if(p>=1 && p<=7)
  27.     {
  28.         cout<<"數量: ";        
  29.         cin>>q;
  30.         if(q>0)
  31.         {
  32.              sum=sum+price[p-1]*q;
  33.              qty[p-1]=q;
  34.              goto start;      
  35.         }else
  36.         {
  37.              cout<<"輸入錯誤!"<<endl;
  38.              goto start;     
  39.         }   
  40.     }else
  41.     {
  42.         cout<<"輸入錯誤!"<<endl;
  43.         goto start;     
  44.     }
  45.     checkout:
  46.     cout<<endl<<"[購物清單]"<<endl;
  47.     cout<<"------------------"<<endl;
  48.     for(int i=0; i<=6; i++)
  49.     {
  50.             if(qty[i]!=0)
  51.             cout<<name[i]<<"\t"<<price[i]<<"元*"<<qty[i]<<"個"<<endl;      
  52.     }  
  53.     cout<<endl<<"總共"<<sum<<"元!"<<endl;
  54.     cout<<"------------------"<<endl;
  55.     back:
  56.     cout<<"(1)繼續(2)重新選購"<<endl;
  57.     cin>>chose;
  58.     if(chose==1)
  59.     {
  60.                 goto go;            
  61.     }else if(chose==2)
  62.     {
  63.           goto start;
  64.     }else
  65.     {
  66.          cout<<"輸入錯誤";
  67.          goto back;     
  68.     }
  69.     go:
  70.     cout<<"請輸入付了多少錢: ";
  71.     cin>>pay;
  72.     money=pay-sum;
  73.     if(money==0)
  74.     {
  75.         cout<<"錢剛剛好! 請慢走!"<<endl;
  76.     }
  77.     if(money<0)
  78.     {
  79.         cout<<"錢不夠! 還欠"<<-money<<endl;                  
  80.     }
  81.     if(money>0)
  82.     {
  83.          cout<<"總共需要找客人"<<money<<"元"<<endl;   
  84.          if(money>=500)
  85.          {
  86.             cout<<"500元鈔票"<<money/500<<"張"<<endl;
  87.             money=money%500;
  88.          }
  89.          if(money>=100)
  90.          {
  91.             cout<<"100元鈔票"<<money/100<<"張"<<endl;
  92.             money=money%100;
  93.          }
  94.          if(money>=50)
  95.          {
  96.             cout<<"50元硬幣"<<money/50<<"枚"<<endl;
  97.             money=money%50;
  98.          }
  99.          if(money>=10)
  100.          {
  101.             cout<<"10元硬幣"<<money/10<<"枚"<<endl;
  102.             money=money%10;
  103.          }
  104.          if(money>=5)
  105.          {
  106.             cout<<"5元硬幣"<<money/5<<"枚"<<endl;
  107.             money=money%5;
  108.          }
  109.          if(money>=1)
  110.          {
  111.             cout<<"1元硬幣"<<money/1<<"枚"<<endl;
  112.             money=money%1;
  113.          }
  114.     }
  115.      system("pause");
  116.     return 0;
  117. }
複製代碼

TOP

本帖最後由 長逸 於 2013-7-27 14:05 編輯
  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()
  5. {   
  6.     re:
  7.     string name[]={"阿姆姆","艾希","安妮","蓋倫","維爾賽","佛德提克"};
  8.     int qty[]={0,0,0,0,0,0};     
  9.     int price[]={1240,136,2584,251,987,654};
  10.     int a,b,sum=0,pay,money,e;
  11.     cout<<"***英雄聯盟***"<<endl;
  12.     cout<<"商品價目表"<<endl;
  13.     cout<<"(1)阿姆姆\t\t1240元"<<endl;
  14.     cout<<"(2)艾希\t\t136元"<<endl;
  15.     cout<<"(3)安妮\t\t2584元"<<endl;
  16.     cout<<"(4)蓋倫\t251元"<<endl;
  17.     cout<<"(5)維爾賽\t\t987元"<<endl;
  18.     cout<<"(6)佛德提克\t\t654元"<<endl;
  19.     cout<<"消費滿5000送提一隻!!(限量  市價1001000元)"<<endl;
  20.     cout<<"選購完時代號都輸入8即可進入結帳頁"<<endl;
  21.     start:
  22.     cout<<"請輸入商品代號:"<<endl;
  23.     cin>>a;
  24.     if(a==8)
  25.     {
  26.          goto end;        
  27.     }
  28.     cout<<"請輸入數量:"<<endl;
  29.     cin>>b;
  30.     if(a>=1 && a<=7 && b>0)
  31.     {   
  32.          sum=sum+price[a-1]*b;
  33.          qty[a-1]=b;
  34.          goto start;        
  35.     }else
  36.     {
  37.          cout<<"輸入錯誤"<<endl;
  38.          goto start;      
  39.     }
  40.     end:
  41.     cout<<endl<<"[購物清單]"<<endl;   
  42.     cout<<"-------------------------------"<<endl;
  43.     for(int i=0;i<=5;i++)
  44.     {   
  45.          if(qty[i]!=0)
  46.          {
  47.                       cout<<name[i]<<"\t"<<price[i]<<"*"<<qty[i]<<"個"<<endl;         
  48.          }                    
  49.     }
  50.     cout<<"-------------------------------"<<endl;     
  51.     cout<<endl<<"\t\t總共"<<sum<<"元!"<<endl;
  52.     cout<<"1正確無誤2重新選購"<<endl;
  53.     cin>>e;
  54.     if(e==1)
  55.     {
  56.          goto good;        
  57.     }else if(e==2)
  58.     {
  59.          goto re;     
  60.     }else
  61.     {
  62.          cout<<"輸入錯誤"<<endl;     
  63.     }
  64.     good:
  65.     if(sum>=5000)
  66.     {
  67.          cout<<"由於消費滿5000,贈送鍍金棺材乙個!!"<<endl;
  68.     }
  69.     cout<<"請輸入付了多少錢: ";
  70.     cin>>pay;
  71.     money=pay-sum;
  72.     if(money==0)
  73.     {
  74.         cout<<"錢剛剛好! 請慢走!"<<endl;
  75.     }
  76.     if(money<0)
  77.     {
  78.         cout<<"錢不夠! 還欠"<<-money<<endl;                  
  79.     }
  80.     if(money>0)
  81.     {
  82.          cout<<"總共需要找客人"<<money<<"元";   
  83.          if(money>=500)
  84.          {
  85.             cout<<"500元鈔票"<<money/500<<"張"<<endl;
  86.             money=money%500;
  87.          }
  88.          if(money>=100)
  89.          {
  90.             cout<<"100元鈔票"<<money/100<<"張"<<endl;
  91.             money=money%100;
  92.          }
  93.          if(money>=50)
  94.          {
  95.             cout<<"50元硬幣"<<money/50<<"枚"<<endl;
  96.             money=money%50;
  97.          }
  98.          if(money>=10)
  99.          {
  100.             cout<<"10元硬幣"<<money/10<<"枚"<<endl;
  101.             money=money%10;
  102.          }
  103.          if(money>=5)
  104.          {
  105.             cout<<"5元硬幣"<<money/5<<"枚"<<endl;
  106.             money=money%5;
  107.          }
  108.          if(money>=1)
  109.          {
  110.             cout<<"1元硬幣"<<money/1<<"枚"<<endl;
  111.             money=money%1;
  112.          }
  113.     }
  114.    
  115.      
  116.     system("pause");   
  117.     return 0;   
  118. }
複製代碼

TOP

本帖最後由 長逸 於 2013-7-27 13:59 編輯
  1. 1
複製代碼

TOP

本帖最後由 劉得旗 於 2013-7-25 01:35 編輯
  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()
  5. {   
  6.     re:
  7.     string name[]={"黃金制棺材  ","檜木製棺材  ","玻璃棺材   ","青花瓷骨灰盆","飲料罐骨灰盆 ","可口可樂玻璃瓶骨灰盆   "};
  8.     int qty[]={0,0,0,0,0,0};     
  9.     int price[]={1240,136,2584,251,987,654};
  10.     int a,b,sum=0,pay,money,e;
  11.     cout<<"@@@死亡屋@@@"<<endl;
  12.     cout<<"商品價目表"<<endl;
  13.     cout<<"(1)黃金制棺材\t\t1200元"<<endl;
  14.     cout<<"(2)檜木製棺材\t\t1250元"<<endl;
  15.     cout<<"(3)玻璃棺材\t\t850元"<<endl;
  16.     cout<<"(4)青花瓷骨灰盆\t\t125元"<<endl;
  17.     cout<<"(5)飲料罐骨灰盆\t\t10元"<<endl;
  18.     cout<<"(6)可口可樂玻璃瓶骨灰盆 25元"<<endl;
  19.     cout<<"消費滿1500送去死!![限量!]"<<endl;
  20.     cout<<"選購完時代號都輸入0即可進入死亡結帳頁"<<endl;
  21.     start:
  22.     cout<<"請輸入死亡商品代號:"<<endl;
  23.     cin>>a;
  24.     if(a==0)
  25.     {
  26.          goto end;        
  27.     }
  28.     cout<<"請輸入數量:"<<endl;
  29.     cin>>b;
  30.     if(a>=1 && a<=7 && b>0)
  31.     {   
  32.          sum=sum+price[a-1]*b;
  33.          qty[a-1]=b;
  34.          goto start;        
  35.     }else
  36.     {
  37.          cout<<"輸入錯誤"<<endl;
  38.          goto start;      
  39.     }
  40.     end:
  41.     cout<<endl<<"[死亡購物清單]"<<endl;   
  42.     cout<<"-------------------------------"<<endl;
  43.     for(int i=0;i<=5;i++)
  44.     {   
  45.          if(qty[i]!=0)
  46.          {
  47.                       cout<<name[i]<<"\t"<<price[i]<<"*"<<qty[i]<<"個"<<endl;         
  48.          }                    
  49.     }
  50.     cout<<"-------------------------------"<<endl;     
  51.     cout<<endl<<"\t\t總共"<<sum<<"元!"<<endl;
  52.     cout<<"1正確無誤2重新選購"<<endl;
  53.     cin>>e;
  54.     if(e==1)
  55.     {
  56.             
  57.          goto good;   
  58.               
  59.     }else if(e==2)
  60.     {
  61.          goto re;     
  62.     }else
  63.     {
  64.          
  65.          cout<<"輸入錯誤!腦殘!"<<endl;
  66.             
  67.     }
  68.     good:
  69.     if(sum>=1500)
  70.     {
  71.                   
  72.          cout<<"由於消費滿1500,送妳去死!!"<<endl;
  73.          
  74.     }
  75.     cout<<"請輸入付了多少錢: ";
  76.    
  77.     cin>>pay;
  78.    
  79.     money=pay-sum;
  80.    
  81.     if(money==0)
  82.    
  83.     {
  84.         cout<<"剛剛好! ㄧ路好走!"<<endl;
  85.         
  86.     }
  87.     if(money<0)
  88.    
  89.     {
  90.                
  91.         cout<<"錢不夠!你別想走!"<<-money<<endl;  
  92.                         
  93.     }
  94.    
  95.     if(money>0)
  96.    
  97.     {
  98.          cout<<"總共需要找死人:"<<money<<"元!";  
  99.            
  100.          if(money>=500)
  101.          
  102.          {
  103.                        
  104.             cout<<"500元鈔票"<<money/500<<"張"<<endl;
  105.             
  106.             money=money%500;
  107.          }
  108.          
  109.          if(money>=100)
  110.          
  111.          {
  112.             cout<<"100元鈔票"<<money/100<<"張"<<endl;
  113.             
  114.             money=money%100;
  115.             
  116.          }
  117.          
  118.          if(money>=50)
  119.          
  120.          {
  121.                      
  122.             cout<<"50元硬幣"<<money/50<<"枚"<<endl;
  123.             
  124.             money=money%50;
  125.             
  126.          }
  127.          
  128.          if(money>=10)
  129.          
  130.          {
  131.                      
  132.             cout<<"10元硬幣"<<money/10<<"枚"<<endl;
  133.             
  134.             money=money%10;
  135.             
  136.          }
  137.          
  138.          if(money>=5)
  139.          
  140.          {
  141.             cout<<"5元硬幣"<<money/5<<"枚"<<endl;
  142.             
  143.             money=money%5;
  144.             
  145.          }
  146.          
  147.          if(money>=1)
  148.          
  149.          {
  150.             cout<<"1元硬幣"<<money/1<<"枚"<<endl;
  151.             
  152.             money=money%1;
  153.             
  154.          }
  155.          
  156.     }
  157.    
  158.      
  159.     system("pause");   
  160.     return 0;   
  161. }
複製代碼

TOP

本帖最後由 張瀚仁 於 2013-7-27 15:39 編輯
  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()
  5. {   
  6.     re:
  7.     string name[]={"一日喪命散  ","含笑半步癲  ","地獄一日遊  ","地獄拔舌體驗卷","爬劍山體驗卷 ","棺材訂做   "};
  8.     int qty[]={0,0,0,0,0,0};     
  9.     int price[]={1240,136,2584,251,987,654};
  10.     int a,b,sum=0,pay,money,e;
  11.     cout<<"***歡樂屋***"<<endl;
  12.     cout<<"商品價目表"<<endl;
  13.     cout<<"(1)一日喪命散\t\t1240元"<<endl;
  14.     cout<<"(2)含笑半步癲\t\t136元"<<endl;
  15.     cout<<"(3)地獄一日遊\t\t2584元"<<endl;
  16.     cout<<"(4)地獄拔舌體驗卷\t251元"<<endl;
  17.     cout<<"(5)爬劍山體驗卷\t\t987元"<<endl;
  18.     cout<<"(6)棺材訂做\t\t654元"<<endl;
  19.     cout<<"死亡一概不負責,消費滿5000送棺材乙個!!(限量  鍍金市價10000元)"<<endl;
  20.     cout<<"選購完時代號輸入8即可進入結帳頁"<<endl;
  21.     start:
  22.     cout<<"請輸入商品代號:"<<endl;
  23.     cin>>a;
  24.     if(a==8)
  25.     {
  26.          goto end;        
  27.     }
  28.     cout<<"請輸入數量:"<<endl;
  29.     cin>>b;
  30.     if(a>=1 && a<=7 && b>0)
  31.     {   
  32.          sum=sum+price[a-1]*b;
  33.          qty[a-1]=b;
  34.          goto start;        
  35.     }else
  36.     {
  37.          cout<<"輸入錯誤"<<endl;
  38.          goto re;      
  39.     }
  40.     end:
  41.     cout<<endl<<"[購物清單]"<<endl;   
  42.     cout<<"-------------------------------"<<endl;
  43.     for(int i=0;i<=5;i++)
  44.     {   
  45.          if(qty[i]!=0)
  46.          {
  47.                       cout<<name[i]<<"\t"<<price[i]<<"*"<<qty[i]<<"個"<<endl;         
  48.          }                    
  49.     }
  50.     cout<<"-------------------------------"<<endl;     
  51.     cout<<endl<<"\t\t總共"<<sum<<"元!"<<endl;
  52.     cout<<"1正確無誤2重新選購"<<endl;
  53.     cin>>e;
  54.     if(e==1)
  55.     {
  56.          goto good;        
  57.     }else if(e==2)
  58.     {
  59.          goto re;     
  60.     }else
  61.     {
  62.          cout<<"輸入錯誤"<<endl;     
  63.     }
  64.     good:
  65.     if(sum>=5000)
  66.     {
  67.          cout<<"由於消費滿5000,贈送鍍金棺材乙個!!"<<endl;
  68.     }
  69.     cout<<"請輸入付了多少錢: ";
  70.     cin>>pay;
  71.     money=pay-sum;
  72.     if(money==0)
  73.     {
  74.         cout<<"錢剛剛好! 請慢走!"<<endl;
  75.     }
  76.     if(money<0)
  77.     {
  78.         cout<<"錢不夠! 還欠"<<-money<<endl;                  
  79.     }
  80.     if(money>0)
  81.     {
  82.          cout<<"總共需要找客人"<<money<<"元";   
  83.          if(money>=500)
  84.          {
  85.             cout<<"500元鈔票"<<money/500<<"張"<<endl;
  86.             money=money%500;
  87.          }
  88.          if(money>=100)
  89.          {
  90.             cout<<"100元鈔票"<<money/100<<"張"<<endl;
  91.             money=money%100;
  92.          }
  93.          if(money>=50)
  94.          {
  95.             cout<<"50元硬幣"<<money/50<<"枚"<<endl;
  96.             money=money%50;
  97.          }
  98.          if(money>=10)
  99.          {
  100.             cout<<"10元硬幣"<<money/10<<"枚"<<endl;
  101.             money=money%10;
  102.          }
  103.          if(money>=5)
  104.          {
  105.             cout<<"5元硬幣"<<money/5<<"枚"<<endl;
  106.             money=money%5;
  107.          }
  108.          if(money>=1)
  109.          {
  110.             cout<<"1元硬幣"<<money/1<<"枚"<<endl;
  111.             money=money%1;
  112.          }
  113.     }
  114.    
  115.      
  116.     system("pause");   
  117.     return 0;   
  118. }
複製代碼

TOP

  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()
  5. {
  6.     string name[]={"四人套房        ","兩人套房        ","七人小木屋        ","孤單一人房        ","百人總統房        ","安靈病房        ","太平間地下房        ","跟泳鱔一夜情套房"};
  7.     int qty[]={0,0,0,0,0,0,0,0};
  8.     int price[]={10000,5000,50000,4444,10,1744,55,10000};
  9.     int h, q, pay, money,sum=0,a;
  10.     cout<<"以諾豪華九星級飯店"<<endl;
  11.     cout<<"[飯店房間價目表]"<<endl;
  12.     cout<<"(1)四人套房\t10000元"<<endl;
  13.     cout<<"(2)兩人套房\t5000元"<<endl;
  14.     cout<<"(3)七人小木屋\t50000元"<<endl;
  15.     cout<<"(4)孤單一人房\t4444元"<<endl;
  16.     cout<<"(5)百人總統房\t10元"<<endl;
  17.     cout<<"(6)安靈病房\t1744元"<<endl;
  18.     cout<<"(7)太平間地下房\t55元"<<endl;
  19.     cout<<"(8)跟詠鱔一夜情套房\t1元"<<endl;
  20.     cout<<"[付費說明]"<<endl;
  21.     cout<<"把要住的房間代號輸入後,再輸入要買幾間"<<endl;
  22.     cout<<"購買完請輸入9前往結帳"<<endl;
  23.     start:
  24.     cout<<"請輸入商品代碼: ";
  25.     cin>>h;
  26.     if(h==9)
  27.     {
  28.     goto checkout;
  29.             }
  30.     else if(h>=1 && h<=8)
  31.     {
  32.          cout<<"請輸入購買數量: ";
  33.          cin>>q;
  34.             if(q>0)
  35.             {
  36.               sum=sum+price[h-1]*q;
  37.               qty[h-1]=q;
  38.               goto start;
  39.             }
  40.     else
  41.         {
  42.              cout<<"輸入錯誤!"<<endl;
  43.              goto start;     
  44.         }      
  45.     }        
  46.     else
  47.     {
  48.         cout<<"什麼年紀了還會輸入錯誤!!"<<endl;
  49.         goto start;
  50.         }
  51.     checkout:
  52.     cout<<"購物清單"<<endl;
  53.     cout<<"$$$$$$$$$$$$$$$$$$$$"<<endl;  
  54.     for(int i=0;i<=7;i++)
  55.     {
  56.           if(qty[i]!=0)  
  57.           cout<<name[i]<<"\t"<<price[i]<<"元 *"<<qty[i]<<"個"<<endl;
  58.             }
  59.     cout<<"$$$$$$$$$$$$$$$$$$$$"<<endl;
  60.     cout<<"1.前去結帳 2-重新選購"<<endl;
  61.     cin>>a;
  62.     if(a==1)
  63.     {
  64.            goto checkout2;
  65.            }
  66.     else if(a==2)
  67.     {
  68.            goto  start;  
  69.                }
  70.     else
  71.     {
  72.            cout<<"什麼年紀了還會輸入錯誤!!"<<endl;  
  73.         }
  74.     checkout2:
  75.     cout<<"\t\t總共是"<<sum<<"元"<<endl;
  76.     cout<<"請輸入客人付了多少錢: ";
  77.     cin>>pay;
  78.     money=pay-sum;
  79.     if(money==0)
  80.     {
  81.         cout<<"錢剛剛好! 請慢走!"<<endl;
  82.     }
  83.     if(money<0)
  84.     {
  85.         cout<<"錢不夠! 還少"<<-money<<endl;                  
  86.     }
  87.     if(money>0)
  88.     {
  89.          cout<<"總共需要找客人"<<money<<"元"<<endl;   
  90.          if(money>=500)
  91.          {
  92.             cout<<"500元鈔票"<<money/500<<"張"<<endl;
  93.             money=money%500;
  94.          }
  95.          if(money>=100)
  96.          {
  97.             cout<<"100元鈔票"<<money/100<<"張"<<endl;
  98.             money=money%100;
  99.          }
  100.          if(money>=50)
  101.          {
  102.             cout<<"50元硬幣"<<money/50<<"枚"<<endl;
  103.             money=money%50;
  104.          }
  105.          if(money>=10)
  106.          {
  107.             cout<<"10元硬幣"<<money/10<<"枚"<<endl;
  108.             money=money%10;
  109.          }
  110.     }     
  111. system("pause");
  112. return 0;
  113. }     
複製代碼

TOP

  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()
  5. {
  6.      string name[]={"憤怒鳥                  ","狼牙棒                   ","冷氣","殺手/一個人","不求人抓抓背快樂抓抓小手","劉博士用過的毛巾","踩劉博士走過的路"};
  7.      int price[]={};
  8.      int qty[]={0,0,0,0,0,0,0};
  9.      int p, q, money, pay, sum=0, a;
  10.      cout<<"劉博士之甚麼都賣店"<<endl<<endl;
  11.      cout<<"[只有聰明人才看的到的價目表]"<<endl;
  12.      cout<<"(1)憤怒鳥\t\t300元/隻"<<endl;
  13.      cout<<"(2)狼牙棒\t\t799元"<<endl;
  14.      cout<<"(3)冷氣\t\t80000元"<<endl;
  15.      cout<<"(4)殺手/一個人\t\t200元"<<endl;
  16.      cout<<"(5)不求人抓抓背快樂抓抓小手\t1399元"<<endl;
  17.      cout<<"(6)劉博士用過的毛巾/條\t100000元"<<endl;
  18.      cout<<"(7)踩劉博士走過的路/一步\t3000元"<<endl;
  19.      cout<<"(8)結帳"<<endl<<endl;
  20.      start:
  21.      cout<<"請輸入商品代碼: ";
  22.      cin>>p;
  23.      if(p==8)
  24.      {
  25.           goto checkout;
  26.      }else if(p>=1 && p<=7)
  27.      {
  28.           cout<<"請輸入數量:";
  29.           cin>>q;
  30.           if(q>0)
  31.           {
  32.              sum=sum+price[p-1]*q;
  33.              qty[p-1]=q;
  34.              goto start;      
  35.         }else
  36.         {
  37.              cout<<"輸入錯誤!"<<endl;
  38.              goto start;     
  39.         }   
  40.      }else
  41.      {
  42.          cout<<"輸入錯誤!"<<endl;
  43.          goto start;     
  44.      }
  45.      checkout:
  46.      cout<<endl<<"[購物清單]"<<endl;
  47.      cout<<"-------------"<<endl;
  48.      for(int i=0; i<=6; i++)
  49.      {
  50.          if(qty[i]!=0)     
  51.             cout<<name[i]<<"\t"<<price[i]<<"元 * "<<qty[i]<<"個"<<endl;
  52.      }
  53.      cout<<"-------------"<<endl;
  54.      cout<<"\t\t總共"<<sum<<"元!"<<endl;
  55.      cout<<"1-正確無誤 2-重新選購"<<endl;
  56.      cout<<"請輸入你要的"<<endl;
  57.      cin>>a;
  58.      if(a==1)
  59.      cout<<"Please摳摳拿來!"<<endl;
  60.      system("pause");
  61.      return 0;   
  62. }     
複製代碼

TOP

本帖最後由 黃崇維 於 2013-7-20 20:30 編輯
  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()
  5. {
  6.      string name[]={"一星級電腦","二星級電腦","三星級電腦","四星級電腦","五星級電腦","六星級電腦","七星級電腦"};
  7.      int price[]={10000,12000,12300,12340,12345,123456,1234567};
  8.      int qty[]={0,0,0,0,0,0,0};
  9.      int p, q, money, pay, sum=0, a;
  10.      cout<<"崇維智能電腦房屋店"<<endl<<endl;
  11.      cout<<"[電腦價目表]"<<endl;
  12.      cout<<"(1)一星級電腦\t10000元"<<endl;
  13.      cout<<"(2)二星級電腦\t12000元"<<endl;
  14.      cout<<"(3)三星級電腦\t12300元"<<endl;
  15.      cout<<"(4)四星級電腦\t12340元"<<endl;
  16.      cout<<"(5)五星級電腦\t12345元"<<endl;
  17.      cout<<"(6)六星級電腦\t123456元"<<endl;
  18.      cout<<"(7)七星級電腦\t1234567元"<<endl;
  19.      cout<<"(8)結帳"<<endl<<endl;
  20.      start:
  21.      cout<<"請輸入商品代碼: ";
  22.      cin>>p;
  23.      if(p==8)
  24.      {
  25.           goto checkout;
  26.      }else if(p>=1 && p<=7)
  27.      {
  28.           cout<<"請輸入數量:";
  29.           cin>>q;
  30.           if(q>0)
  31.           {
  32.              sum=sum+price[p-1]*q;
  33.              qty[p-1]=q;
  34.              goto start;      
  35.         }else
  36.         {
  37.              cout<<"輸入錯誤!"<<endl;
  38.              goto start;     
  39.         }   
  40.      }else
  41.      {
  42.          cout<<"輸入錯誤!"<<endl;
  43.          goto start;     
  44.      }
  45.      checkout:
  46.      cout<<endl<<"[購物清單]"<<endl;
  47.      cout<<"-------------"<<endl;
  48.      for(int i=0; i<=6; i++)
  49.      {
  50.          if(qty[i]!=0)     
  51.             cout<<name[i]<<"\t"<<price[i]<<"元 * "<<qty[i]<<"個"<<endl;
  52.      }
  53.      cout<<"-------------"<<endl;
  54.      cout<<"\t\t總共"<<sum<<"元!"<<endl;
  55.      cout<<"1-正確無誤 2-重新選購"<<endl;
  56.      cout<<"請輸入你的決定"<<endl;
  57.      cin>>a;
  58.      if(a==1)
  59.      cout<<"請交出你的錢!"<<endl;

  60.      system("pause");
  61.      return 0;   
  62. }     
複製代碼

TOP

返回列表