返回列表 發帖
  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()
  5. {
  6.     int p,q,sum=0;
  7.     string name[5]={"CAD   ","NERvGear","蘿球   ","密斯提斯","吉太    "};
  8.     int price[5]={10000,20000,20000,10000,10000};
  9.     cout<<"<?<?<?<<動漫道具店>>?>?>?>"<<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<<"(6)結帳"<<endl<<endl;
  16.     re:
  17.     cout<<"請輸入商品代碼: ";
  18.     cin>>p;
  19.     if(p==6)
  20.     goto checkout;
  21.     else if(p>=1 && p<=5)
  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.     checkout:
  37.     qty[p-1]+=q;
  38.     cout<<"---------------------"<<endl;
  39.     for(int i=0;i<7;i++)
  40.     {
  41.          if(qty[i]>0)
  42.          cout<<name[i]<<"\t"<<price[i]<<"元"<<qty[i]<<"個"<<endl;
  43.     }
  44.     cout<<"---------------------"<<endl;
  45.     goto re;
  46.     cheakout;
  47.     cout<<endl<<"總共"<<sum<<"元!"<<endl;
  48.     system("pause");
  49.     return 0;   
  50. }
複製代碼
http://fs-old.mis.kuas.edu.tw/~s1102137106/music/

TOP

返回列表