欢迎来到天天文库
浏览记录
ID:56761147
大小:45.50 KB
页数:13页
时间:2020-07-07
《算法设计和分析_最小花费购物问题.doc》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、//----//Bussiness.h//#include#include#include#includeclassProduct{public:voidSetNO(intno){if(no<1
2、
3、no>999){std::cout<<"wrongNO.";}else{m_nNO=no;}}intGetNO(){returnm_nNO;}voidSetPrice(intprice){if(price<1
4、
5、price>999){std::cout<<"wrongprice";}else{m_nPrice=pric
6、e;}}intGetPrice(){returnm_nPrice;}private:intm_nNO;//商品编码[1,999];intm_nPrice;//单独购买的单价[1,999];};classItem{public:voidSetNO(intno){if(no<1
7、
8、no>999){std::cout<<"wrongNO.";}else{m_nNO=no;}}intGetNO(){returnm_nNO;}voidSetCount(intcount){if(count<1
9、
10、count>5){std::cout<<"wrongcount";}else{m_nCount=coun
11、t;}}intGetCount(){returnm_nCount;}voidSubCount(intnSub){m_nCount-=nSub;}private:intm_nNO;//商品编码[1,999];intm_nCount;//购买该商品的个数[1,5];};classDiscountType{public:intm_nSize;//该折扣组合的商品种类数;int*m_pNOs;//对应的商品编号;int*m_pCount;//对应每种商品需要的个数;intm_nOffer;//该种优惠方案所需花销;//intm_nSave;//相对于原价节省的钱;intGetProductCou
12、nt(intnProNO)//返回该方案下需要nProNO的个数;{intcount=0;//一个很大的数超过了单件采购的最高限度;for(inti=0;i13、m_pItems=newItem[m_nCount];for(inti=0;i14、DicTypeCount;//促销方案的种类;intGetProductPrice(intnProNO);private:intBackspaceMinCost(Purchase&purch,intdiscTypeID);boolSatisfiedDemand(Purchase&purch,intdiscTypeID);voidUpdatePurchase(Purchase&purch,intdiscTypeID);};constintMAX_PIECE=5;constintMAX_PRODUCT_CODE=999;constintMAX_PURCH_NUM=5;classSchedue15、lCost{public:ScheduelCost();voidInit(Shop&theShop,Purchase&thePurchase);voidComp(inti);voidOut();private:voidMiniCost();intB;//购买物品的数目上限;intS;//优惠折扣的类型总数,小于99;intm_cost[MAX_PIECE+1][MAX_PIECE+1][MAX_PIECE+1][MAX_PIECE+
13、m_pItems=newItem[m_nCount];for(inti=0;i14、DicTypeCount;//促销方案的种类;intGetProductPrice(intnProNO);private:intBackspaceMinCost(Purchase&purch,intdiscTypeID);boolSatisfiedDemand(Purchase&purch,intdiscTypeID);voidUpdatePurchase(Purchase&purch,intdiscTypeID);};constintMAX_PIECE=5;constintMAX_PRODUCT_CODE=999;constintMAX_PURCH_NUM=5;classSchedue15、lCost{public:ScheduelCost();voidInit(Shop&theShop,Purchase&thePurchase);voidComp(inti);voidOut();private:voidMiniCost();intB;//购买物品的数目上限;intS;//优惠折扣的类型总数,小于99;intm_cost[MAX_PIECE+1][MAX_PIECE+1][MAX_PIECE+1][MAX_PIECE+
14、DicTypeCount;//促销方案的种类;intGetProductPrice(intnProNO);private:intBackspaceMinCost(Purchase&purch,intdiscTypeID);boolSatisfiedDemand(Purchase&purch,intdiscTypeID);voidUpdatePurchase(Purchase&purch,intdiscTypeID);};constintMAX_PIECE=5;constintMAX_PRODUCT_CODE=999;constintMAX_PURCH_NUM=5;classSchedue
15、lCost{public:ScheduelCost();voidInit(Shop&theShop,Purchase&thePurchase);voidComp(inti);voidOut();private:voidMiniCost();intB;//购买物品的数目上限;intS;//优惠折扣的类型总数,小于99;intm_cost[MAX_PIECE+1][MAX_PIECE+1][MAX_PIECE+1][MAX_PIECE+
此文档下载收益归作者所有