本帖最後由 曾宥程 於 2019-10-19 08:16 編輯
- #include<iostream>
- #include<cstdlib>
- using namespace std;
- int main()
- {
- string item[]={"koreafish(一盒87隻) ","花媽造型餅乾(一盒87片)","馬櫻酒 ","館長牌雞肉 "
- ,"空心蔡英文 ","柯P的手表 ","'蝦子'小餅乾 ",};
- int price[]={1450,870,690,399,150,5000,450,0};
- cout<<"======???????店======"<<endl<<endl;
- cout<<"[商品價目表]"<<endl;
- int p,q,sum=0;
- for(int i=0; i<7; i++)
- cout<<"("<<i+1<<")"<<item[i]<<"\t"<<price[i]<<"元"<<endl;
- cout<<"<8>結帳"<<endl;
- re:
- cout<<"請輸入商品代號: ";
- cin>>p;
- if(p>=1 && p<=7)
- {
- cout<<"數量:";
- cin>>q;
- if(q>0)
- {
- sum=sum+price[p-1]*q;
- goto re;
- }
- }else if(p==8)
- {
- goto checkout;
- }else
- {
- cout<<"輸入錯誤!!!!!!!!!!!"<<endl;
- goto re;
- }
- checkout:
- cout<<"總金額是"<<sum<<"元"<<endl;
-
- system("pause");
- return 0;
- }
複製代碼 |