返回列表 發帖
  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()
  5. {
  6.     int price[]={450,550,325,200,660,150,380};
  7.     int p,q,sum=0;
  8.     cout<<"槍的店"<<endl<<endl;
  9.     cout<<"[殺手表]"<<endl;
  10.     cout<<"(1)黑白雙煞\t123元"<<endl;
  11.     cout<<"(2)金蠍雙擊\t132元"<<endl;
  12.     cout<<"(3)準雷\t213元"<<endl;
  13.     cout<<"(4)赤玉魔龍\t\t231元"<<endl;
  14.     cout<<"(5)紅白雙心\t312元"<<endl;
  15.     cout<<"(6)碎骨銀狼\t321元"<<endl;
  16.     cout<<"(7)藍寶槍\t\t123元"<<endl;
  17.     cout<<"(8)結帳"<<endl<<endl;
  18.     start:
  19.     cout<<"請輸入商品代碼: ";
  20.     cin>>p;
  21.     if(p==8)
  22.     {
  23.         goto checkout;
  24.     }else if(p>=1 && p<=7)
  25.     {
  26.         cout<<"數量: ";        
  27.         cin>>q;
  28.         if(q>0)
  29.         {
  30.              sum=sum+price[p-1]*q;
  31.              goto start;      
  32.         }else
  33.         {
  34.              cout<<"輸入錯誤!"<<endl;
  35.              goto start;     
  36.         }   
  37.     }else
  38.     {
  39.         cout<<"輸入錯誤!"<<endl;
  40.         goto start;     
  41.     }
  42.     checkout:
  43.     cout<<endl<<"總共"<<sum<<"元!"<<endl;   
  44.     system("pause");
  45.     return 0;
  46. }
複製代碼

TOP

返回列表