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

  38.    cout<<total<<"元"<<endl;  
  39.    
  40.    
  41.    system("pause");
  42.    return 0;
  43. }
複製代碼

TOP

返回列表