返回列表 發帖
  1. #include<iostream>
  2. using namespace std;
  3. int main(){
  4.     re:
  5.     system("cls");
  6.     int p,q,sum=0;
  7.     string name[]={"傷藥","解麻藥","好傷藥","寶貝球","高級球"};
  8.     int  price[]={200,400,500,200,800};
  9.         cout<<"   寶可夢商店   "<<endl<<endl;  
  10.     cout<<"[商品價格表]"<<endl;
  11.    
  12.     for(int i=0; i<5; i++)
  13.          cout<<"("<<i+1<<")"<<name[i]<<"\t"<<price[i]<<"元"<<endl;
  14.           cout<<"(6)結帳"<<endl<<endl;
  15.     re2:
  16.     cout<<"請輸入商品代碼:";
  17.     cin>>p;
  18.     if(p==6)
  19.     {
  20.         goto checkout;
  21.     }else if(p>=1 && p<=5)
  22.     {
  23.         cout<<"數量:";
  24.         cin>>q;
  25.         sum+=price[p-1]*q;
  26.         goto re2;  
  27.     }else
  28.     {
  29.         goto re;     
  30.     }
  31.     checkout:
  32.     cout<<endl<<"總共"<<sum<<"元!"<<endl;         
  33.    
  34.        
  35.         system("pause");
  36.     goto re;   
  37.     return 0;
  38. }
複製代碼

TOP

返回列表