本帖最後由 劉泳鱔 於 2013-7-6 15:19 編輯
- #include<iostream>
- #include<cstdlib>
- using namespace std;
- int main()
- {
- int price[]={450,550,325,200,660,150,380};
- int p,q,sum=0;
- cout<<"$$超能商店$$"<<endl;
- cout<<"[商品價格]"<<endl;
- cout<<"(1)屎一斤\t550元"<<endl;
- cout<<"(2)坦克模型\t550元"<<endl;
- cout<<"(3)魔球\t\t325元"<<endl;
- cout<<"(4)藍圖\t\t200元"<<endl;
- cout<<"(5)機關槍\t660元"<<endl;
- cout<<"(6)驚悚玩偶\t150元"<<endl;
- cout<<"(7)保齡球\t\t380元"<<endl;
- cout<<"[使用說明]"<<endl;
- cout<<"依序輸入想購買的商品與數量,如籃球兩顆請輸入'7 2'"<<endl;
- cout<<"選購完畢時輸入'8 8'進入結帳頁"<<endl<<endl;
- start:
- cout<<"在此輸入: ";
- cin>>p;
- if(p==8)
- {
- goto checkout;
- }
- else if(p>=1 && p<=7 && q>0)
- {
- sum=sum+price[p-1]*q;
- goto start;
- }else if(p==8 && q==8)
- {
- goto checkout;
- }else
- {
- cout<<"輸入錯誤!"<<endl;
- goto start;
- }
- checkout:
- cout<<endl<<"總共"<<sum<<"元!"<<endl;
- system("pause");
- return 0;
- }
複製代碼 |