返回列表 發帖
本帖最後由 曾宥程 於 2019-10-19 08:16 編輯
  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()
  5. {
  6.     string item[]={"koreafish(一盒87隻)    ","花媽造型餅乾(一盒87片)","馬櫻酒               ","館長牌雞肉                "
  7.     ,"空心蔡英文            ","柯P的手表                ","'蝦子'小餅乾               ",};
  8.     int price[]={1450,870,690,399,150,5000,450,0};
  9.     cout<<"======???????店======"<<endl<<endl;
  10.     cout<<"[商品價目表]"<<endl;
  11.     int p,q,sum=0;
  12.     for(int i=0; i<7; i++)
  13.          cout<<"("<<i+1<<")"<<item[i]<<"\t"<<price[i]<<"元"<<endl;
  14.     cout<<"<8>結帳"<<endl;
  15.     re:
  16.     cout<<"請輸入商品代號: ";
  17.     cin>>p;
  18.     if(p>=1 && p<=7)
  19.     {
  20.         cout<<"數量:";
  21.         cin>>q;
  22.         if(q>0)
  23.         {
  24.             sum=sum+price[p-1]*q;
  25.                         goto re;      
  26.         }
  27.         }else if(p==8)
  28.         {
  29.                 goto checkout;
  30.                 }else
  31.                 {
  32.                         cout<<"輸入錯誤!!!!!!!!!!!"<<endl;
  33.                         goto re;
  34.                 }
  35.                 checkout:
  36.                         cout<<"總金額是"<<sum<<"元"<<endl;
  37.          
  38.     system("pause");   
  39.     return 0;
  40. }
複製代碼

TOP

返回列表