- #include<iostream>
- #include<cstdlib>
- using namespace std;
- int main()
- {
- int a,b,c=0;
- cout<<"◎◎◎玩具店◎◎◎"<<endl<<endl<<"[商品價目表]"<<endl;
- string t[8]={"遙控汽車","飛機模型","足球","拼圖","玩具槍","可愛玩偶","籃球","結帳"};
- int p[7]={450,550,325,200,660,150,380};
- for(int i=0;i<7;i++)
- {
- cout<<"〈"<<i+1<<"〉"<<t[i]<<"\t";
- cout<<p[i]<<"元"<<endl;
- }
- cout<<"〈8〉結帳"<<endl;
- re:
- cout<<"請輸入商品代碼: ";
- cin>>a;
- if(a > 0 && a < 8)
- {
- cout<<"數量: ";
- cin>>b;
- a=p[a-1];
- c+=a*b;
- goto re;
- }else if(a==8)
- {
- cout<<"總共"<<c<<"元"<<endl;
- }else
- {
- cout<<"輸入錯誤!!!"<<endl;
- goto re;
- }
- system("pause");
- return 0;
- }
複製代碼 |