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

TOP

返回列表