返回列表 發帖
  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()
  5. {
  6.     re2:
  7.     int p,q,sum=0,option,pay,money;
  8.     string name[7]={"速效跳課糖","米你毛毛球","無頭帽","金斯雀奶油蛋糕","攜帶型沼澤","假魔杖","伸縮耳"};
  9.     int price[7]={90,80,74,3,80,1,4};
  10.     int qty[7]={0,0,0,0,0,0,0};
  11.     cout<<"****衛氏巫師法寶店****"<<endl<<endl;
  12.     cout<<"[商品價目表]"<<endl;
  13.     for(int i=0; i<7; i++)
  14.     {
  15.         cout<<"("<<i+1<<")"<<name[i]<<"\t"<<price[i]<<"元"<<endl;
  16.     }
  17.     cout<<"(8)結帳"<<endl<<endl;
  18.     cout<<"[加隆任務]消費100加隆送假魔丈*30"
  19.     re:
  20.     cout<<"請輸入商品代碼: ";
  21.     cin>>p;
  22.     if(p==8)
  23.         goto checkout;
  24.     else if(p>=1 && p<=7)
  25.     {
  26.         cout<<"數量: ";
  27.         cin>>q;
  28.         if(q<=0)
  29.         {
  30.             cout<<"錯誤!"<<endl;
  31.             goto re;        
  32.         }
  33.         sum+=price[p-1]*q;
  34.         qty[p-1]+=q;         
  35.     }
  36.     else
  37.     {
  38.         cout<<"錯誤!"<<endl;   
  39.     }
  40.     goto re;
  41.     checkout:
  42.     cout<<endl<<"[魔法清單]"<<endl;         
  43.     cout<<"-----------------------------"<<endl;
  44.     for(int i=0; i<7; i++)
  45.     {
  46.         if(qty[i]!=0)
  47.             cout<<name[i]<<"\t"<<price[i]<<"加隆 * "<<qty[i]<<"個"<<endl;  
  48.     }
  49.     cout<<"-----------------------------"<<endl;
  50.      if(sum >= 100)
  51.     {
  52.            cout<<"你消費"<<sum<<"加隆,符合滿100加隆的任務"<<endl<<endl;
  53.            cout<<"假魔丈*30是你的了!"<<endl;
  54.     }         
  55.     cout<<"總共"<<sum<<"加隆!"<<endl<<endl;
  56.     cout<<"1-正確無誤 2-重新選購  ";
  57.     cin>>option;
  58.     if(option==1)
  59.     {
  60.         goto change;
  61.     }
  62.     else
  63.     {
  64.         system("cls");     
  65.         goto re2;
  66.     }
  67.     change:
  68.     cout<<endl<<"請付帳: ";
  69.     cin>>pay;
  70.     money=pay-sum;
  71.     if(money==0)
  72.     {
  73.         cout<<"感謝光臨!"<<endl;
  74.     }
  75.     else if(money<0)
  76.     {
  77.         cout<<"快把"<<-money<<"加隆交來!"<<endl;
  78.         goto change;     
  79.     }else
  80.     {
  81.         cout<<"找你"<<money<<"加隆"<<endl;
  82.         if(money>=100)
  83.         {
  84.             cout<<"100加隆"<<money/100<<"枚"<<endl;
  85.             money%=100;
  86.         }
  87.         if(money>=50)
  88.         {
  89.             cout<<"50加隆"<<money/50<<"枚"<<endl;
  90.             money%=50;         
  91.         }
  92.         if(money>=10)
  93.         {
  94.             cout<<"10加隆"<<money/10<<"枚"<<endl;
  95.             money%=10;         
  96.         }
  97.         if(money>0)
  98.         {
  99.             cout<<"1加隆"<<money<<"枚"<<endl;
  100.         }               
  101.     }
  102.     cout<<endl<<"下次再來"<<endl;
  103.     system("pause");
  104.     return 0;   
  105. }
複製代碼

TOP

  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()
  5. {
  6.     re2:
  7.     int p,q,sum=0,option,pay,money;
  8.     string name[7]={"速效跳課糖  ","米你毛毛球  ","無頭帽    ","金斯雀奶油蛋糕","攜帶型沼澤  ","假魔杖    ","伸縮耳    "};
  9.     int price[7]={90,80,74,3,80,1,4};
  10.     int qty[7]={0,0,0,0,0,0,0};
  11.     cout<<"****衛氏巫師法寶店****"<<endl<<endl;
  12.     cout<<"[商品價目表]"<<endl;
  13.     for(int i=0; i<7; i++)
  14.     {
  15.         cout<<"("<<i+1<<")"<<name[i]<<"\t"<<price[i]<<"元"<<endl;
  16.     }
  17.     cout<<"(8)結帳"<<endl<<endl;
  18.     cout<<"[加隆任務]消費100加隆送假魔丈*30"<<endl;
  19.     re:
  20.     cout<<"請輸入商品代碼: ";
  21.     cin>>p;
  22.     if(p==8)
  23.         goto checkout;
  24.     else if(p>=1 && p<=7)
  25.     {
  26.         cout<<"數量: ";
  27.         cin>>q;
  28.         if(q<=0)
  29.         {
  30.             cout<<"錯誤!"<<endl;
  31.             goto re;        
  32.         }
  33.         sum+=price[p-1]*q;
  34.         qty[p-1]+=q;         
  35.     }
  36.     else
  37.     {
  38.         cout<<"錯誤!"<<endl;   
  39.     }
  40.     goto re;
  41.     checkout:
  42.     cout<<endl<<"[魔法清單]"<<endl;         
  43.     cout<<"-----------------------------"<<endl;
  44.     for(int i=0; i<7; i++)
  45.     {
  46.         if(qty[i]!=0)
  47.             cout<<name[i]<<"\t"<<price[i]<<"加隆 * "<<qty[i]<<"個"<<endl;  
  48.     }
  49.     cout<<"-----------------------------"<<endl;
  50.      if(sum >= 100)
  51.     {
  52.            cout<<"你消費"<<sum<<"加隆,符合滿100加隆的任務"<<endl<<endl;
  53.            cout<<"假魔丈*30是你的了!"<<endl;
  54.     }         
  55.     cout<<"總共"<<sum<<"加隆!"<<endl<<endl;
  56.     cout<<"1-正確無誤 2-重新選購  ";
  57.     cin>>option;
  58.     if(option==1)
  59.     {
  60.         goto change;
  61.     }
  62.     else
  63.     {
  64.         system("cls");     
  65.         goto re2;
  66.     }
  67.     change:
  68.     cout<<endl<<"請付帳: ";
  69.     cin>>pay;
  70.     money=pay-sum;
  71.     if(money==0)
  72.     {
  73.         cout<<"感謝光臨!"<<endl;
  74.     }
  75.     else if(money<0)
  76.     {
  77.         cout<<"快把"<<-money<<"加隆交來!"<<endl;
  78.         goto change;     
  79.     }else
  80.     {
  81.         cout<<"找你"<<money<<"加隆"<<endl;
  82.         if(money>=100)
  83.         {
  84.             cout<<"100加隆"<<money/100<<"枚"<<endl;
  85.             money%=100;
  86.         }
  87.         if(money>=50)
  88.         {
  89.             cout<<"50加隆"<<money/50<<"枚"<<endl;
  90.             money%=50;         
  91.         }
  92.         if(money>=10)
  93.         {
  94.             cout<<"10加隆"<<money/10<<"枚"<<endl;
  95.             money%=10;         
  96.         }
  97.         if(money>0)
  98.         {
  99.             cout<<"1加隆"<<money<<"枚"<<endl;
  100.         }               
  101.     }
  102.     cout<<endl<<"下次再來"<<endl;
  103.     system("pause");
  104.     return 0;   
  105. }
複製代碼

TOP

返回列表