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

TOP

返回列表