返回列表 發帖
  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()
  5. {
  6.    cout<<"☆★☆智能玩具店☆★☆"<<endl;
  7.    string f[7]=
  8.     {
  9.              "(1)遙控汽車",
  10.              "(2)飛機模型",
  11.              "(3)足球    ",
  12.              "(4)拼圖    ",
  13.              "(5)玩具槍  ",
  14.              "(6)可愛玩偶",
  15.              "(7)籃球    "
  16.     };
  17.    int n[7]={450,550,325,200,660,150,380};
  18.    
  19.     for(int i=0;i<7;i++)
  20.      {
  21.            cout<<f[i]<<"\t"<<n[i]<<"元"<<endl;
  22.      }
  23.     int num=0;
  24.     int count=0;
  25.     int total=0;
  26.      cout<<"輸入0結帳"<<endl;
  27.   while(true)
  28.    {
  29.      cout<<"請輸入商品代碼"<<endl;
  30.      cin>>num;   
  31.      if(num==0)
  32.      {   
  33.        break;
  34.      }
  35.      cout<<"請輸入數量"<<endl;
  36.      cin>>count;
  37.      total=total+n[num-1]*count;   
  38.    }
  39.      cout<<"總金額:"<<total<<endl;
  40.     system("pause");
  41.     return 0;
  42. }
複製代碼

TOP

返回列表