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

TOP

返回列表