返回列表 發帖
  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()
  5. {
  6.     int p,q,sum=0;
  7.     string name[6]={"雪莉(玩偶)","黑雞 鐵鏟 氫氣氣球","炸彈    ","鉛筆模型      ","明太子(炸彈)      ","史派克      "};
  8.     int price[6]={0,658,95110,45454,78945,9214};
  9.     cout<<"史派克丸劇墊"<<endl<<endl;
  10.     cout<<"[商品架木表]"<<endl;
  11.     for(int i=0;i<6;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.     {
  19.              goto checkout;
  20.     }else if(p>=1&& p<=7)
  21.     {
  22.           cout<<"數量:";
  23.           cin>>q;
  24.           sum+price[p-1]*q;
  25.           goto re;
  26.     }else
  27.     {
  28.          goto re;
  29.     }
  30.     checkout:     
  31.     cout<<endl<<"總共"<<sum<<"元!"<<endl<<endl;                                                  
  32.     system("pause");
  33.     return 0;
  34. }
複製代碼

TOP

返回列表