完成修正版- #include<iostream>
- using namespace std;
- int main ()
- {
- cout<<"☆★☆《影武的網路速食店》☆★☆"<<endl;
- cout<<endl;
- cout<<"〔商品價目表〕"<<endl;
- string list[8]={"薯條","漢堡","可樂","雪碧","奶昔","紅茶","披薩","結帳"};
- int inventory[7]={0,0,0,0,0,0,0};
- int money[7]={50,80,45,45,55,45,299};
- for ( int i=0 ; i<8 ; i++)
- {
- cout<<"("<<i+1<<")"<<list[i]<<""<<"\t";
- if (i!=7){
- cout<<money[i]<<"元"<<endl;
- }
-
- }
- cout<<endl;
- int sum=0;
- while (true)
- {
- int a=0,b=0;
- cout<<"請輸入代碼"<<endl;
- cin>>a;
- if(a==8){
- break;
- }else{
- cout<<"數量"<<endl;
- cin>>b;
- inventory[a-1]+=b;
- sum += money[a-1]*b;
- }
- }
- cout<<"《收據》"<<endl;
- cout<<"影武網路速食店"<<endl;
- cout<<"地址 : 火星芭樂國香蕉市西瓜區哈密瓜社區一路0號"<<endl;
- cout<<"電話 : 您播的電話是空號,請查明後再播,謝謝!"<<endl;
- cout<<"購買日期 : 3684年13月32日 "<<endl;
- cout<<"購買時間 : 25時83分92秒"<<endl;
- cout<<"服務人員 : 魔法師影武"<<endl;
- cout<<"*請於25分鐘後至本店取餐*"<<endl;
- cout<<"-----------------------------------"<<endl;
- for(int i=0;i<7;i++)
- {
- if(inventory[i]!=0)
- {
- cout<<list[i]<<"\t";
- cout<<money[i]<<"*";
- cout<<inventory[i]<<endl;
- }
- }
- if(sum==0)
- cout<<"\t(空白)"<<endl;
- cout<<"-----------------------------------"<<endl;
- cout<<"總金額"<<sum<<"元"<<endl;
- system("pause");
- return 0;
- }
複製代碼 |