返回列表 發帖
  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()
  5. {
  6.     int t, q, total=0;
  7.     string n[5]={"玩具車","熊玩偶","羽毛球","乒乓球","玩具槍"};
  8.     int p[5]={450,300,30,10,600};
  9.     cout<<"☆智能玩具店☆"<<endl<<endl;
  10.     cout<<"商品價目表"<<endl<<endl;
  11.     for(int i=0; i<5; i++)
  12.     {
  13.            cout<<"("<<i+1<<")"<<n[i]<<"\t"<<p[i]<<"元"<<endl;   
  14.     }   
  15.     cout<<"請輸入8來結帳"<<endl<<endl;
  16.     re:
  17.     cout<<"請輸入商品代碼:";
  18.     cin>>t;
  19.     if(t==8)
  20.     {
  21.          goto checkout;        
  22.     }else if(t>0 && t<8)
  23.     {
  24.        cout<<"數量:";
  25.        cin>>q;
  26.        total+=p[t-1]*q;
  27.        goto re;     
  28.     }else
  29.     {
  30.        goto re ;   
  31.     }
  32.     checkout:
  33.     cout<<endl<<"總共"<<total<<"元!"<<endl<<endl;   
  34.     system("pause");
  35.     return 0;
  36. }
複製代碼

TOP

返回列表