- #include<iostream>
- #include<cstdlib>
- using namespace std;
- int main()
- {
- cout<<"智能玩具店"<<endl;
- string name [7]={"(1)遙控汽車","(2)遙控飛機","(3)足球","(4)評圖","(5)玩具槍","(6)可愛玩偶","(7)籃球"};
- int num[7]={450,550,325,200,660,150,380};
- for (int i=0;i<7;i++)
- {
- cout<<name[i]<<"\t";
- cout<<num[i]<<endl;
- }
- cout<<endl;
- int productnumber=0;
- int count=0;
- int total=0;
- cout<<"請輸入-1離開"<<endl;
- while(true)
- {
- cout<<"商店代碼"<<endl;
- cin>>productnumber;
- if(productnumber==-1)
- {break;
- }
- cout<<"數量"<<endl;
- cin>>count;
- total=total+num[count-1]*count;
- }
- cout<<"總金"<<total<<endl;
- system("pause");
- return 0;
- }
複製代碼 |