返回列表 發帖
  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main(){
  5. re:
  6.     system("cls");
  7.     int x,y,sum=0;
  8.     int t[7]={0};
  9.     string n[7]={"遙控汽車","飛機模型","足球  ","拼圖  ","玩具槍 ","可愛玩偶","籃球  "};
  10.     int p[7]={450,550,325,200,660,150,380};

  11.     cout<<"***智能玩具店***"<<endl;
  12.     cout<<"[價目表]"<<endl;
  13.     for(int i=0;i<7;i++)
  14.         cout<<"("<<i+1<<")"<<n[i]<<"\t"<<p[i]<<"元"<<endl;
  15.     cout<<"(8)結帳"<<endl;
  16. re2:
  17.     cout<<"請輸入商品代號: "<<endl;
  18.     cin>>x;
  19.     if(x==8)
  20.         goto checkout;
  21.     else if(x>=1&&x<=7){
  22.         cout<<"輸入數量"<<endl;
  23.         cin>>y;
  24.         sum+=p[x-1]*y;
  25.         t[x-1]=t[x-1]+y;
  26.         goto re2;
  27.     }
  28.     else
  29.         goto re;
  30.     checkout:
  31.         cout<<"[購物清單]"<<endl;
  32.         cout<<"--------------------------------"<<endl;
  33.         for(int i=0;i<7;i++){
  34.             if(t[i]>0)
  35.             cout<<n[i]<<"\t"<<p[i]<<"元*"<<t[i]<<endl;
  36.         }
  37.         cout<<"--------------------------------"<<endl;
  38.         cout<<"總共"<<sum<<"元"<<endl;

  39. system("pause");
  40. goto re;
  41. return 0;

  42. }
複製代碼

TOP

返回列表