返回列表 發帖
  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()
  5. {
  6.     int z,f,sum=0;
  7.    
  8.     string x[]={"菠蘿麵包   ","小餐包(六入)  ","巧克力熱壓吐司","紅豆麵包   ","桂圓麵包   ","培根玉米三明治","北歐圓法(四入)"};
  9.     int y[]={35,50,45,30,55,65,45};

  10.     cout<<"左營可口麵包店"<<endl<<endl;
  11.     cout<<"{麵包價目表]"<<endl;
  12.    
  13.      for(int i=0;i<7;i++)
  14.     {
  15.         cout<<"("<<i+1<<")"<<x[i]<<"\t"<<y[i]<<"元"<<endl;
  16.     }
  17.     cout<<"(8)結帳"<<endl<<endl;
  18.     while(true)
  19.     {
  20.         cout<<"請輸入商品代碼: ";
  21.         cin>>z;
  22.         if(z==8)
  23.           break;
  24.         cout<<"數量: ";
  25.         cin>>f;
  26.         sum+=y[z-1]*f;                    
  27.     }
  28.     cout<<endl<<"共"<<sum<<"元!"<<endl;
  29.     system("pause");
  30.     return 0;            
  31. }
複製代碼

TOP

返回列表