本帖最後由 蔡季樺 於 2016-4-20 14:30 編輯
- #include<iostream>
- #include<cstdlib>
- using namespace std;
- int main()
- {
- string name[8]={"火焰藥水","放屁藥水","作夢藥水","打呵欠藥水","超人藥水","打老師藥水","萬能藥水","結帳"};
- int money[7]={200,50,100,10,2000,1100,100000000};
- int commodity,quantity,checkout=0;
- cout<<"~~★☆★沒路用的藥水專賣店☆★☆~~"<<endl;
- cout<<"[價目表]"<<endl;
- for(int i=0; i<=6; i++)
- {
- cout<<"("<<i+1<<")"<<name[i]<<"\t"<<money[i]<<"元"<<endl;
- }
- cout<<"("<<"8"<<")"<<name[7]<<endl;
- while(commodity!=8)
- {
- cout<<"請輸入想要買的商品代碼(結帳按8):";
- cin>>commodity;
- if(commodity==8)
- break;
- cout<<"請輸入要買的數量:";
- cin>>quantity;
- checkout+=quantity*money[commodity-1];
-
- }
- cout<<"總共要付"<<checkout<<"元!"<<endl;
- system("pause");
- return 0;
- }
複製代碼 |