返回列表 發帖
  1. #include<iostream>
  2. using namespace std;
  3. int main ()
  4. {
  5.     cout<<"☆★☆《影武的網路速食店》☆★☆"<<endl;
  6.     cout<<endl;
  7.     cout<<"〔商品價目表〕"<<endl;
  8.     string list[8]={"薯條","漢堡","可樂","雪碧","奶昔","紅茶","披薩","結帳"};
  9.     int money[7]={50,80,45,45,55,45,299};
  10.     for ( int i=0 ; i<8 ; i++)
  11.      {
  12.         cout<<"("<<i+1<<")"<<list[i]<<""<<"\t";
  13.         if (i!=7){
  14.                   cout<<money[i]<<"元"<<endl;
  15.                   }
  16.                         
  17.      }
  18.      cout<<endl;
  19.      int sum=0;
  20.      while (true)
  21.      {
  22.            int a=0,b=0;
  23.            cout<<"請輸入代碼"<<endl;
  24.            cin>>a;
  25.            if(a==8){
  26.                  break;
  27.            }else{
  28.                  cout<<"數量"<<endl;
  29.                  cin>>b;
  30.                  sum += money[a-1]*b;
  31.            }

  32.      }
  33.      cout<<"收您"<<sum<<"元"<<endl;
  34.      system("pause");
  35.      return 0;
  36. }
複製代碼

TOP

返回列表