返回列表 發帖
  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()
  5. {
  6.       
  7.   string name[]={"球1","球2","球3","球4","球5","球6","球7"};
  8.     int price[]={100,100,100,100,100,1000,100};
  9.     cout<<"☆★☆玩具店☆★☆"<<endl;
  10.     cout<<"[商品價目表]"<<endl;
  11.     cout<<"          "<<endl;
  12.     cout<<"   "<<endl;
  13.      
  14.     for(int i=0; i<7; i++ )
  15.     {
  16.        cout<<"("<<i+1<<")"<<name[i]<<"\t"<<price[i]<<"元"<<endl;
  17.       
  18.     }   
  19.     system("pause");
  20.     return 0;   
  21. }
複製代碼

TOP

  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()
  5. {
  6.      re:
  7.        system("cls");   
  8.   string name[]={"球1","球2","球3","球4","球5","球6","球7"};
  9.   
  10.     int price[]={100,100,100,100,100,1000,100};
  11.     cout<<"☆★☆玩具店☆★☆"<<endl;
  12.     cout<<"[商品價目表]"<<endl;
  13.     cout<<"          "<<endl;
  14.    
  15.      
  16.     for(int i=0; i<7; i++ )
  17.     {
  18.        cout<<"("<<i+1<<")"<<name[i]<<"\t"<<price[i]<<"元"<<endl;
  19.       
  20.     }
  21.      cout<<"<8>結帳"<<endl;
  22.       int tempn=0;
  23.       
  24.      cout<<"輸入商品代碼"<<endl;
  25.      cin>>tempN;   
  26.    
  27.      if(p==8)
  28.      {
  29.      goto checkout;
  30.      
  31.      
  32.      }
  33.      else if(p>=1&&p<=7)
  34.      {
  35.       cout<<"數量";     
  36.       cin>>q;
  37.       sum+=price[p-1]*q;
  38.       goto re2;
  39.       }
  40.       else
  41.       {     
  42.        goto re;   
  43.        }   
  44.            
  45.            
  46.      }   
  47.      
  48.      
  49.       
  50.     system("pause");
  51.     goto re;
  52.     return 0;   
  53. }
複製代碼

TOP

返回列表