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