返回列表 發帖
  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()
  5. {
  6.     int p,q,sum=0;
  7.     string name[5]={"砍頭優惠卷","特效搖頭丸","自殺體驗卷","被打免費票","舒柔鼻涕蟲",};
  8.     int price[5]={99111,458645,14000,99999,100000};
  9.     cout<<"☆★☆智能玩具店☆★☆"<<endl<<endl;
  10.     cout<<"[商品價目表]"<<endl;
  11.     for(int i=0; i<5; i++)
  12.     {
  13.         cout<<"("<<i+1<<")"<<name[i]<<"\t"<<price[i]<<"元"<<endl;
  14.     }
  15.     cout<<"(8)結帳"<<endl<<endl;
  16.     re:
  17.     cout<<"請輸入商品代碼: ";
  18.     cin>>p;
  19.     if(p==8)
  20.         goto checkout;
  21.     else if(p>=1 && p<=7)
  22.     {
  23.         cout<<"數量: ";
  24.         cin>>q;
  25.         if(q<=0)
  26.         {
  27.             cout<<"輸入錯誤!"<<endl;
  28.             goto re;        
  29.         }
  30.         sum+=price[p-1]*q;     
  31.     }
  32.     else
  33.     {
  34.         cout<<"輸入錯誤!"<<endl;   
  35.     }
  36.     goto re;
  37.     checkout:
  38.     cout<<endl<<"總共"<<sum<<"元!"<<endl;
  39.     system("pause");
  40.     return 0;   
  41. }
複製代碼

TOP

返回列表