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