- #include<iostream>
- #include<cstdlib>
- using namespace std;
- int main()
- {
- re:
- system("cls");
- int p,q,sum=0;
- string name[]={"遙控器車","飛機模型","籃球 "};
- int price[]={450,550,300};
- cout<<"智能玩具店"<<endl<<endl;
- cout<<"[商品價目]"<<endl;
- for(int i=0; i<3; i++)
-
- cout<<"("<<i+1<<")"<<name[i]<<"\t"<<price[i]<<"元"<<endl;
- cout<<"(8)結帳"<<endl<<endl;
- re2:
- cout<<"請輸入商品代碼: ";
-
- cin>>p;
- if(p==8)
- {
- goto checkout;
-
- }else if(p>=1&&p<=1)
- {
- cout<<"數量: ";
- cin>>q;
- sum+=price[p-1]*q;
- goto re2;
- }else
- {
- goto re;
- }
- checkout:
- cout<<"總共"<<sum<<"元"<<endl;
- system("pause");
- return 0;
- }
複製代碼 |