返回列表 發帖
  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()
  5. {
  6.     int price[7]={790, 870, 110, 230, 950, 770, 375};
  7.     string name[8]={"遙控汽車","飛機模型","足球","拼圖","玩具槍","可愛玩偶","籃球","結帳"};
  8.     cout << "[商品價目表]" << endl;      
  9.     for(int i = 0; i < 7; i++)                                                                              
  10.         cout << "(" << i+1 << ")" << name[i] << "    " << "\t" << price[i] << "元" << endl;
  11.     cout << "(8)" << name[7] <<endl;
  12.     int b=0;
  13.     int a=0;
  14.     while(a!=8){
  15.         int c;
  16.         cout << "請輸入商品代碼:";   
  17.         cin >> a;
  18.         if(a==8)
  19.             break;
  20.         cout << "數量:";   
  21.         cin >> c;
  22.         b+=price[a-1]*c;
  23.     }
  24.     cout << b << endl;
  25.      
  26.     system("pause");
  27.     return 0;
  28. }
複製代碼

TOP

返回列表