返回列表 發帖
  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()
  5. {
  6.      re:
  7.      string tag[9]={"(1)即刻槍戰","(2)勇士法則","(3)遊戲桃",

  8.                    "(4)雪球大戰","(5)遊戲天堂","(6)熱血精靈派",

  9.                    "(7)塞爾號","(8)minecraft"};

  10.     int price[8]={9900,7000,200,300,200,500,500,1000};

  11.     cout<<"\t*** 智能線上遊戲店 ***"<<endl<<"本店商品保證讚(雖然是黑心貨)"<<endl<<endl;
  12.     cout<<"[商品一覽表]"<<endl;
  13.     for(int i=0; i<8; i++){
  14.        cout<<"<"<<i+1<<">"<<tag[i]<<"\t\t"<<price[i]<<"元"<<endl;   
  15.     }
  16.     cout<<"<9>結帳去"<<"\t\t"<<endl<<endl;
  17.     cout<<"[優惠方案]\t本店滿5000元及立刻打九折"<<endl<<endl;
  18.     B:
  19.     int qty[]={0,0,0,0,0,0,0,0};
  20.     int num=0,lab,q,c, pay,coin;
  21.     A:                                                         
  22.     cout<<"請輸入商品代碼: ";
  23.     cin>>lab;
  24.     if(lab==9)
  25.       goto checkout;
  26.     else if(lab>=0){
  27.       cout<<"數量: ";
  28.       cin>>q;
  29.       num+=price[lab-1]*q;
  30.       qty[lab-1]+=q;
  31.       goto A;         
  32.     }  
  33.     else{
  34.       cout<<"輸入錯誤"<<endl;      
  35.       goto A;   
  36.     }  
  37.     checkout:
  38.     cout<<endl<<"[購物清單]"<<endl;
  39.     cout<<"----------------------------"<<endl;
  40.     for(int i=0; i<=7; i++){
  41.       if(qty[i]!=0)        
  42.         cout<<tag[i]<<"\t"<<price[i]<<"元 * "<<qty[i]<<"個"<<endl;
  43.     }
  44.     cout<<"----------------------------"<<endl;  
  45.     cout<<endl<<"共"<<num<<"元"<<endl<<endl;
  46.     cout<<"1-正確無誤 2-重新選購 ";
  47.     cin>>c;
  48.     if(c==2){
  49.       cout<<endl;
  50.       goto B;
  51.       num=0;
  52.     }
  53.     if(c==1){
  54.        p:
  55.        cout<<endl;
  56.        cout<<"請您付帳: ";
  57.        cin>>pay;
  58.        if(pay<num&&pay>0){
  59.          cout<<"您付的錢不夠,還差"<<num-pay<<"元"<<endl;
  60.          goto p;         
  61.        }
  62.        else if(pay<=0){
  63.          cout<<"混水摸魚的奧客,請付錢"<<endl;
  64.          goto p;
  65.        }
  66.        else{
  67.          coin=pay-num;   
  68.          cout<<endl<<"感謝,找您"<<coin<<"元!"<<endl;     
  69.          if(coin>=1000){   
  70.             cout<<"1000元大鈔"<<coin/1000<<"張"<<endl;
  71.             coin%=1000;
  72.          }
  73.          if(coin>=100){   
  74.             cout<<"100元大鈔"<<coin/100<<"張"<<endl;
  75.             coin%=100;
  76.          }
  77.          if(coin>=50){   
  78.             cout<<"50元摳摳"<<coin/50<<"枚"<<endl;
  79.             coin%=50;
  80.          }
  81.          if(coin>=10){   
  82.             cout<<"10元摳摳"<<coin/10<<"枚"<<endl;
  83.             coin%=10;
  84.          }
  85.          if(coin>=5){   
  86.             cout<<"5元摳摳"<<coin/5<<"枚"<<endl;
  87.             coin%=5;
  88.          }
  89.          if(coin>=1){   
  90.             cout<<"1元摳摳"<<coin/1<<"枚"<<endl;
  91.          }
  92.       }
  93.     }   
  94.     cout<<endl<<"再次感謝您使用本系統"<<endl;
  95.     goto re;                                   
  96.     system("pause");   
  97.     return 0;
  98. }
複製代碼
我是眾神之王XXX  I love you
0000000000

TOP

返回列表