返回列表 發帖
  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()
  5. {
  6.    cout<<"智能玩具店"<<endl;
  7.      string name [7]={"(1)遙控汽車","(2)遙控飛機","(3)足球","(4)評圖","(5)玩具槍","(6)可愛玩偶","(7)籃球"};   
  8.     int num[7]={450,550,325,200,660,150,380};  
  9.     for (int i=0;i<7;i++)
  10.     {
  11.           cout<<name[i]<<"\t";
  12.        cout<<num[i]<<endl;
  13. }
  14. cout<<endl;
  15. int productnumber=0;
  16. int count=0;
  17. int total=0;

  18. cout<<"請輸入-1離開"<<endl;
  19. while(true)
  20. {
  21. cout<<"商店代碼"<<endl;
  22. cin>>productnumber;
  23. if(productnumber==-1)
  24. {break;
  25. }
  26. cout<<"數量"<<endl;
  27. cin>>count;
  28. total=total+num[count-1]*count;

  29. }
  30. cout<<"總金"<<total<<endl;
  31.     system("pause");  
  32.   return 0;
  33. }   
複製代碼

TOP

返回列表