- #include<iostream>
- #include<cstdlib>
- using namespace std;
- int main()
- {
- int p,q,sum=0;
- string name[6]={"雪莉(玩偶)","黑雞 鐵鏟 氫氣氣球","炸彈 ","鉛筆模型 ","明太子(炸彈) ","史派克 "};
- int price[6]={0,658,95110,45454,78945,9214};
- cout<<"史派克丸劇墊"<<endl<<endl;
- cout<<"[商品架木表]"<<endl;
- for(int i=0;i<6;i++)
- cout<<"("<<i+1<<")"<<name[i]<<"\t"<<price[i]<<"元"<<endl;
- cout<<"(8)結帳"<<endl<<endl;
- re:
- cout<<"請輸入商品代碼:";
- cin>>p;
- if (p==8)
- {
- goto checkout;
- }else if(p>=1&& p<=7)
- {
- cout<<"數量:";
- cin>>q;
- sum+price[p-1]*q;
- goto re;
- }else
- {
- goto re;
- }
- checkout:
- cout<<endl<<"總共"<<sum<<"元!"<<endl<<endl;
- system("pause");
- return 0;
- }
複製代碼 |