返回列表 發帖
  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()
  5. {
  6.     string a[]{"遙控汽車","飛機模型","足球    ","拼圖    ","玩具槍  ","可愛玩偶","籃球    ",};
  7.     int b[]={450,550,325,200,660,150,380};


  8.     cout<<"☆★☆智能玩具店☆★☆"<<endl<<endl;
  9.     cout<<"商品價目表"<<endl;
  10.     for(int i=0; i<7;  i++)
  11.     {
  12.         cout<<"<"<<i+1<<">"<<a[i]<<"\t"<<b[i]<<"元"<<endl;
  13.     }
  14.     cout<<"<8>結帳"<<endl;
  15.     re:

  16.     cout<<endl;
  17.     int x,y,w=-1,sum=0;

  18.     re2:
  19.     cout<<"請輸入商品代碼:";
  20.     cin>>x;
  21.     if(x==8)
  22.     {
  23.         goto out;
  24.     }
  25.     else if(x>=1&&x<=7)
  26.     {
  27.         cout<<"請輸入購買數量:";
  28.         cin>>y;
  29.         sum+=b[x-1]*y;
  30.         goto re2;
  31.     }
  32.     else
  33.     {
  34.         cout<<"輸入錯誤"<<endl;
  35.         goto re2;
  36.     }
  37.     out:
  38.     cout<<endl;
  39.     cout<<endl<<"總共"<<sum<<"元!"<<endl;


  40.     system("pause");
  41.     return 0;
  42. }
複製代碼

TOP

返回列表