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