- #include<iostream>
- #include<cstdlib>
- using namespace std;
- int main()
- {
- re:
- int p,q,sum=0;
- string name[]={"步槍 ","機關槍","狙擊槍","雷射槍","反坦克步槍","火箭炮","手槍 "};
- int price[]={30,45,60,50,90,75,10};
- cout<<"=====智能武器店====="<<endl<<endl;
- cout<<"[商品價目表]"<<endl;
- for(int i=0; i<7; i++)
- cout<<"("<<i+1<<")"<<name[i]<<"\t"<<price[i]<<"萬元"<<endl;
-
- cout<<"(8)結帳"<<endl<<endl;
- re2:
- cout<<"請輸入商品代碼: ";
- cin>>p;
- if(p==8)
- {
- goto checkout;
- }else if(p>=1 && p<=7)
- {
- cout<<"數量: ";
- cin>>q;
- sum+=price[p-1]*q;
- goto re2;
- }else
- {
- goto re;
- }
- checkout:
- system("pause");
- return 0;
- }
複製代碼 |