返回列表 發帖
本帖最後由 王建葦 於 2019-10-19 10:03 編輯
  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()
  5. {
  6.     string name[]={"Millet           "
  7.                   ,"SONY             "
  8.                   ,"Samsung          "
  9.                   ,"OPPO             "
  10.                   ,"APPLE            "
  11.                   ,"Koreafish        "
  12.                   ,"ASUS             "
  13.                   ,"VegetablesEnglish"};
  14.     int price[]={9000,7000,7000,8000,50000,0,9000,0};
  15.     cout<<"=====不知道賣什麼的專賣店====="<<endl<<endl;
  16.     cout<<"[商品價目表]"<<endl;
  17.     int p,q,sum=0;
  18.     for(int i=0; i<7; i++)
  19.     {
  20.          cout<<"("<<i+1<<")"<<name[i]<<"\t"<<price[i]<<"元"<<endl;
  21.     }
  22.     cout<<"(8)結帳"<<endl<<endl;
  23.     re:
  24.     cout<<"請輸入商品代碼:";
  25.     cin>>p;
  26.    
  27.     if(p>=1 && p<=7)
  28.     {
  29.         cout<<"數量:";
  30.         cin>>q;
  31.         if(q>0)
  32.         {
  33.             sum=sum+price[p-1]*q;
  34.             goto re;
  35.         }else
  36.         {
  37.             cout<<"輸入錯誤!!!"<<endl;
  38.             goto re;
  39.         }
  40.     }
  41.     else if(p==8)
  42.     {
  43.          goto checkout;
  44.     }else
  45.     {
  46.          cout<<"輸入錯誤!!!"<<endl;
  47.          goto re;
  48.     }
  49.     checkout:
  50.         cout<<"總金額:"<<sum<<"元"<<endl;
  51.         
  52.    
  53.     system("pause");   
  54.     return 0;
  55. }
複製代碼
Jian-wei Wang

TOP

返回列表