返回列表 發帖
  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()
  5. {
  6.     int price[]={1240,136,2584,251,987,654};
  7.     int a,b,sum=0;
  8.     cout<<"***歡樂屋***"<<endl;
  9.     cout<<"商品價目表"<<endl;
  10.     cout<<"(1)一日喪命散\t\t1240元"<<endl;
  11.     cout<<"(2)含笑半步癲\t\t136元"<<endl;
  12.     cout<<"(3)地獄一日遊\t\t2584元"<<endl;
  13.     cout<<"(4)地獄拔舌體驗卷\t251元"<<endl;
  14.     cout<<"(5)爬劍山體驗卷\t\t987元"<<endl;
  15.     cout<<"(6)棺材訂做\t\t654元"<<endl;
  16.     cout<<"死亡一概不負責,消費滿5000送棺材乙個!!(限量  鍍金市價10000元)"<<endl;
  17.     cout<<"依序輸入想購買的商品與數量,如一日喪命散兩份請輸入'1 2'"<<endl;
  18.     cout<<"選購完畢時輸入'8 8'進入結帳頁"<<endl<<endl;
  19.     start:
  20.     cout<<"請輸入:"<<endl;
  21.     cin>>a>>b;
  22.     if(a>=1 && a<=7 && b>0)
  23.     {
  24.          sum=sum+price[a-1]*b;
  25.          goto start;        
  26.     }else if(a==8 && b==8)
  27.     {
  28.          goto end;   
  29.     }
  30.     else  
  31.     {
  32.          cout<<"輸入錯誤"<<endl;      
  33.     }
  34.     end:
  35.     cout<<endl<<"總共"<<sum<<"元!"<<endl;
  36.     if(sum>=5000)
  37.     {
  38.          cout<<"由於消費滿5000,贈送鍍金棺材乙個!!"<<endl;
  39.     }            
  40.     system("pause");   
  41.     return 0;   
  42. }
複製代碼

TOP

返回列表