- #include <iostream>
- #include <cstdlib>
- using namespace std;
- int main()
- {
- int buy[7];
- int buycount[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;
- int number=0;
-
- cout<<"輸入-1離開:"<<endl;
-
- while (true)
- {
-
- while(true)
- {
- cout<<"商品代碼:"<<endl;
- cin>>a;
- if(a==-1)
- {
- break;
- }
- cout<<"是否繼續購買(1)yes(2)No"<<endl;
- cin>>number;
- if(number==1)
- {
- continue;
- }
- else
- {
- buy[index]=a;
- cout<<"數量:"<<endl;
- cin>>z;
- buycount[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]<<"元"<<buycount[i]<<"個"<<endl;
- }
- cout<<"------------------------"<<endl;
- cout<<"總金額:"<<w<<endl;
- }
- system("pause");
- return 0;
- }
複製代碼 |