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

  28.         }
  29.     }
  30.     else{
  31.         goto re;
  32.     }





  33.     checkout:
  34.     cout<<endl<<"總共"<<r<<"元!"<<endl;

  35.     system("pause");
  36.     goto re;
  37.     return 0;
  38. }
複製代碼

TOP

返回列表