- #include<iostream>
- #include<cstdlib>
- using namespace std;
- int main()
- {
- re:
- system("cls");
- int p,q,sum=0;
- cout<<"☆★☆智能雜貨店 ☆★☆"<<endl<<endl;
- string name[6]={"礦泉水","柳橙汁","可口可樂-小","可口可樂-中","可口可樂-大","結帳"};
- int price[5]={10,15,20,25,30};
- cout<<"商品價目表"<<endl;
- for(int i=0; i<5; i++)
- cout<<"("<<i+1<<")"<<name[i]<<"\t"<<price[i]<<"元"<<endl;
- cout<<"(6)"<<name[5]<<endl;
- re2:
- cout<<"請輸入商品代碼:";
- cin>>p;
- if(p==6)
- {
- goto checkout;
- }else if(p>=1 && p<=5)
- {
- cout<<"數量:";
- cin>>q;
- sum+=price[p-1]*q;
- goto re2;
- }else
- {
- goto re;
- }
- checkout:
- cout<<"總共"<<sum<<"元"<<endl;
- system("pause");
- goto re;
- return 0;
- }
複製代碼 |