返回列表 發帖
  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()
  5. {
  6.     int p,q,sum=0;
  7.     string c[]={"遙控汽車\t",
  8.                 "飛機模型\t",
  9.                 "足球\t        ",
  10.                 "拼圖\t        ",
  11.                 "玩具槍\t",
  12.                 "可愛玩偶\t",
  13.                 "籃球\t        "};
  14.     int n[]={450,550,325,200,660,150,380};
  15.     cout<<"▲▲▲智障玩具店▲▲▲"<<endl<<endl;
  16.     cout<<"[商品價目表]"<<endl;
  17.     for(int i=0; i<7; i++)
  18.        cout<<"<"<<i+1<<">"<<c[i]<<n[i]<<"元"<<endl;
  19.     cout<<endl;
  20.     re:
  21.     cout<<"請輸入商品代碼 (若想結帳,請輸入8) : ";
  22.     cin>>p;
  23.     if(p==8)
  24.        goto out;
  25.     else if(p>=1 && p<=7)
  26.     {
  27.         cout<<"數量:";
  28.         cin>>q;
  29.         sum+=n[p-1]*q;
  30.         goto re;
  31.     }
  32.     else
  33.     {
  34.         goto re;
  35.     }
  36.     out:
  37.         cout<<endl<<"總共"<<sum<<"元!!!!!!!"<<endl;
  38.     system("pause");
  39.     return 0;   
  40. }
複製代碼

TOP

返回列表