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