- #include <iostream>
- #include <cstdlib>
- using namespace std;
- int main()
- {
- int buy[7];
- int buya[7];
- cout<<"智能玩具店"<<endl;
- string num[7]={"(1)遙控車","(2)遙控飛機","(3)足球 ","(4)拼圖 ","(5)籃球 ","(6)玩具槍","(7)娃娃"};
- int n[7]={750,550,555,78,885,1999,85};
- for(int i=0;i<7;i++)
- {
- cout<<num[i]<<"\t";
- cout<<n[i]<<"\t";
- cout<<endl;
- }
- int a=0;
- int z=0;
- int w=0;
- int index=0;
- cout<<"輸入-1離開:"<<endl;
- while(true)
- {
- cout<<"商品代碼:"<<endl;
- cin>>a;
- if(a==-1)
- {
- break;
- }
- buy[index]=a;
- cout<<"數量:"<<endl;
- cin>>z;
- buya[index]=z;
- w= w+n[a-1]*z;
- index++;
- }
-
- cout<<"購物清單"<<endl;
- cout<<"--------------------"<<endl;
- for(int i=0;i<index;i++)
- {
- cout<<num[buy[i]-1]<<"\t"<<n[buy[i]-1]<<"元*"<<buya[i]<<"個" <<endl;
-
- }
- cout<<"--------------------"<<endl;
- cout<<"總金額:"<<w<<endl;
- system("pause");
- return 0;
- }
複製代碼 |