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