本帖最後由 蔡庭豪 於 2016-4-30 11:24 編輯
- #include<iostream>
- #include<cstdlib>
- using namespace std;
- int main()
- {
- int number[7]={450,550,325,200,660,150,380};
- int count[7]={0,0,0,0,0,0,0};
- string name[8]={"遙控汽車 ","飛機模型 ","足球 ","拼圖 ","玩具gun","可愛玩偶 ","籃球 ","結帳"};
- cout<<"======================================"<<endl;
- cout<<"===智障玩具店========================="<<endl;
- cout<<"......................................"<<endl;
- cout<<"===商品價目表========================="<<endl;
- for(int i=0;i<7;i++)
- {
- cout<<"("<<i+1<<")"<<name[i]<<"\t";
- if(i!=7)
- {
- cout<<number[i]<<"元"<<endl;
- }
- }
- int sum = 0;
- while(true)
- {
- int x=0,y=0;
- cout<<"請輸入代碼(按8結帳):";
- cin>>x;
- if(x==8)
- {
- break;
- }
- else
- { cout<<"請輸入數量:";
- cin>>y;
- count[x-1]+=y;
- sum+=number[x-1]*y;
- }
-
- }
- cout<<"[購物清單]"<<endl;
- cout<<"---------------------------------"<<endl;
- for(int i=0;i<7;i++)
- {
- if(count[i]!=0)
- {
- cout<<name[i]<<" "<<number[i]<<"*"<<count[i]<<"="<<number[i]*count[i]<<endl;
- }
- }
- cout<<"---------------------------------"<<endl;
- cout<<"總共"<<sum<<"元"<<endl;
- system("pause");
- return 0;
- }
複製代碼 |