返回列表 發帖
  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main(){
  5.     string tag[8]={"俠盜列車手5         ","決勝時刻:黑色行動3","虹彩六號:圍突行動 ",
  6.                    "minecraft           ","星際大戰:戰場前線 ","正當防衛3         ",
  7.                    "湯姆克蘭西:末日邊界","潛龍諜影:幻痛     "};
  8.     int price[8]={2250,2250,1790,990,2500,1900,1500,2200};
  9.     cout<<"\t※※※子耕電玩專賣店※※※"<<endl<<"本店商品保證便宜^_^"<<endl<<endl;
  10.     cout<<"[商品一覽表]"<<endl;
  11.     for(int i=0; i<8; i++){
  12.        cout<<"<"<<i+1<<">"<<tag[i]<<"\t\t"<<price[i]<<"元"<<endl;   
  13.     }
  14.     cout<<"<9>結帳去"<<"\t\t"<<endl<<endl;
  15.     cout<<"[優惠方案]\t本店滿5000元及立刻打九折"<<endl<<endl;
  16.     B:
  17.     int qty[]={0,0,0,0,0,0,0,0};
  18.     int num=0,lab,q,c, pay,coin;
  19.     A:                                                         
  20.     cout<<"請輸入商品代碼: ";
  21.     cin>>lab;
  22.     if(lab==9)
  23.       goto checkout;
  24.     else if(lab>=0){
  25.       cout<<"數量: ";
  26.       cin>>q;
  27.       num+=price[lab-1]*q;
  28.       qty[lab-1]+=q;
  29.       goto A;         
  30.     }  
  31.     else{
  32.       cout<<"輸入錯誤"<<endl;      
  33.       goto A;   
  34.     }  
  35.     checkout:
  36.     cout<<endl<<"[購物清單]"<<endl;
  37.     cout<<"----------------------------"<<endl;
  38.     for(int i=0; i<=7; i++){
  39.       if(qty[i]!=0)        
  40.         cout<<tag[i]<<"\t"<<price[i]<<"元 * "<<qty[i]<<"個"<<endl;
  41.     }
  42.     cout<<"----------------------------"<<endl;  
  43.     cout<<endl<<"共"<<num<<"元"<<endl<<endl;
  44.     if(num>=5000){
  45.       cout<<"由於消費滿五千,享九折優惠!!"<<endl;              
  46.       cout<<"您只需付"<<num*0.9<<"元! 現省"<<num*0.1<<"元!"<<endl;
  47.       num*=0.9;
  48.     }              
  49.     cout<<"1-正確無誤 2-重新選購 ";
  50.     cin>>c;
  51.     if(c==2){
  52.       cout<<endl;
  53.       num=0;
  54.       goto B;
  55.     }
  56.     else if(c==1){
  57.        p:
  58.        cout<<endl;
  59.        cout<<"請您付帳: ";
  60.        cin>>pay;
  61.        if(pay<num&&pay>0){
  62.          cout<<"您付的錢不夠,還差"<<num-pay<<"元"<<endl;
  63.          goto p;         
  64.        }
  65.        else if(pay<=0){
  66.          cout<<"奧客,請付錢"<<endl;
  67.          goto p;
  68.        }
  69.        else{
  70.          coin=pay-num;   
  71.          cout<<endl<<"感謝,找您"<<coin<<"元!"<<endl;     
  72.          if(coin>=1000){   
  73.             cout<<"1000元大鈔"<<coin/1000<<"張"<<endl;
  74.             coin%=1000;
  75.          }
  76.          if(coin>=500){   
  77.             cout<<"500元大鈔"<<coin/500<<"張"<<endl;
  78.             coin%=500;
  79.          if(coin>=100){   
  80.             cout<<"100元大鈔"<<coin/100<<"張"<<endl;
  81.             coin%=100;
  82.          }
  83.          if(coin>=50){   
  84.             cout<<"50元摳摳"<<coin/50<<"枚"<<endl;
  85.             coin%=50;
  86.          }
  87.          if(coin>=10){   
  88.             cout<<"10元摳摳"<<coin/10<<"枚"<<endl;
  89.             coin%=10;
  90.          }
  91.          if(coin>=5){   
  92.             cout<<"5元摳摳"<<coin/5<<"枚"<<endl;
  93.             coin%=5;
  94.          }
  95.          if(coin>=1){   
  96.             cout<<"1元摳摳"<<coin/1<<"枚"<<endl;
  97.          }
  98.       }
  99.     }   
  100.     cout<<endl<<"再次感謝您使用本系統"<<endl;                                   
  101.     system("pause");   
  102.     return 0;
  103. }
複製代碼
ABCDEFGHIJKLMNOPQRSTUVWXYZ

TOP

返回列表