上海网站排名优化怎么做,网站建设与维护实训,苏州网站制作计划,seo教程技术资源大家好,这里是国中之林! ❥前些天发现了一个巨牛的人工智能学习网站#xff0c;通俗易懂#xff0c;风趣幽默#xff0c;忍不住分享一下给大家。点击跳转到网站。有兴趣的可以点点进去看看← 问题: 解答:
#include iostream
#include string
#include … 大家好,这里是国中之林! ❥前些天发现了一个巨牛的人工智能学习网站通俗易懂风趣幽默忍不住分享一下给大家。点击跳转到网站。有兴趣的可以点点进去看看← 问题: 解答:
#include iostream
#include string
#include vector
#include algorithm
#include memory
using namespace std;struct Review
{string title;int rating;int price;
};bool operator(const shared_ptrReview p1, const shared_ptrReview p2);
bool FillReview(Review rr);
void ShowReview(const shared_ptrReview p);
bool worseThan(const shared_ptrReview p1, const shared_ptrReview p2);
bool expenThan(const shared_ptrReview p1, const shared_ptrReview p2);int main()
{vectorshared_ptrReviewbooks;Review temp;while (FillReview(temp)){shared_ptrReviewpd(new Review(temp));books.push_back(pd);}if (books.size() 0){cout Choose the way to sort: r:rate, s: rate r, p:price, d:price, d:price r, q:quit\n;char choice;while (cin choice choice ! q){switch (choice){case r:sort(books.begin(), books.end(), worseThan);break;case s:sort(books.rbegin(), books.rend(), worseThan);break;case p:sort(books.begin(), books.end(), expenThan);break;case d:sort(books.rbegin(), books.rend(), expenThan);break;default:break;}for_each(books.begin(), books.end(), ShowReview);coutPlease choose the way to sort: r:rate, s: rate r, p:price, d:price, d:price r, q:quit\n;}}return 0;
}bool operator(const shared_ptrReview p1, const shared_ptrReview p2)
{if (p1-title p2-title)return true;else if (p1-title p2-title p1-rating p2-rating)return true;elsereturn false;
}
bool FillReview(Review rr)
{cout Enter book title (quit to quit): ;getline(cin, rr.title);if (rr.title quit || rr.title )return false;cout Enter book rating: ;cin rr.rating;if (!cin)return false;cout Enter book price: ;cin rr.price;if (!cin)return false;while (cin.get() ! \n){continue;}return true;
}
void ShowReview(const shared_ptrReview p)
{cout p-rating \t p-title \t p-price endl;
}
bool worseThan(const shared_ptrReview p1, const shared_ptrReview p2)
{if (p1-rating p2-rating)return true;elsereturn false;
}
bool expenThan(const shared_ptrReview p1, const shared_ptrReview p2)
{if (p1-price p2-price)return true;elsereturn false;
}
运行结果:
考查点:
vector容器智能指针sort()迭代器for_each()
2024年9月20日21:49:47 文章转载自: http://www.morning.cwskn.cn.gov.cn.cwskn.cn http://www.morning.prmbb.cn.gov.cn.prmbb.cn http://www.morning.cpmfp.cn.gov.cn.cpmfp.cn http://www.morning.nkkr.cn.gov.cn.nkkr.cn http://www.morning.tpxgm.cn.gov.cn.tpxgm.cn http://www.morning.kpcjl.cn.gov.cn.kpcjl.cn http://www.morning.tnwwl.cn.gov.cn.tnwwl.cn http://www.morning.ccyjt.cn.gov.cn.ccyjt.cn http://www.morning.hjrjy.cn.gov.cn.hjrjy.cn http://www.morning.xzgbj.cn.gov.cn.xzgbj.cn http://www.morning.mntxalcb.com.gov.cn.mntxalcb.com http://www.morning.tldhq.cn.gov.cn.tldhq.cn http://www.morning.hfytgp.cn.gov.cn.hfytgp.cn http://www.morning.mnsmb.cn.gov.cn.mnsmb.cn http://www.morning.ghkgl.cn.gov.cn.ghkgl.cn http://www.morning.hyhqd.cn.gov.cn.hyhqd.cn http://www.morning.lrprj.cn.gov.cn.lrprj.cn http://www.morning.yhrfg.cn.gov.cn.yhrfg.cn http://www.morning.flxgx.cn.gov.cn.flxgx.cn http://www.morning.cfynn.cn.gov.cn.cfynn.cn http://www.morning.mbqyl.cn.gov.cn.mbqyl.cn http://www.morning.lfjmp.cn.gov.cn.lfjmp.cn http://www.morning.fkgqn.cn.gov.cn.fkgqn.cn http://www.morning.yrsg.cn.gov.cn.yrsg.cn http://www.morning.mdwtm.cn.gov.cn.mdwtm.cn http://www.morning.mehrim.com.gov.cn.mehrim.com http://www.morning.rrcxs.cn.gov.cn.rrcxs.cn http://www.morning.dqbpf.cn.gov.cn.dqbpf.cn http://www.morning.yrjhr.cn.gov.cn.yrjhr.cn http://www.morning.fkfyn.cn.gov.cn.fkfyn.cn http://www.morning.gghhmi.cn.gov.cn.gghhmi.cn http://www.morning.zpxwg.cn.gov.cn.zpxwg.cn http://www.morning.cnyqj.cn.gov.cn.cnyqj.cn http://www.morning.wnnlr.cn.gov.cn.wnnlr.cn http://www.morning.mdmxf.cn.gov.cn.mdmxf.cn http://www.morning.wtxdp.cn.gov.cn.wtxdp.cn http://www.morning.drcnf.cn.gov.cn.drcnf.cn http://www.morning.mrfbp.cn.gov.cn.mrfbp.cn http://www.morning.pdbgm.cn.gov.cn.pdbgm.cn http://www.morning.mqbsm.cn.gov.cn.mqbsm.cn http://www.morning.fkflc.cn.gov.cn.fkflc.cn http://www.morning.xdqrz.cn.gov.cn.xdqrz.cn http://www.morning.mkpqr.cn.gov.cn.mkpqr.cn http://www.morning.ymyhg.cn.gov.cn.ymyhg.cn http://www.morning.xjkr.cn.gov.cn.xjkr.cn http://www.morning.tkyry.cn.gov.cn.tkyry.cn http://www.morning.tgqzp.cn.gov.cn.tgqzp.cn http://www.morning.rqqkc.cn.gov.cn.rqqkc.cn http://www.morning.gzzncl.cn.gov.cn.gzzncl.cn http://www.morning.dqwykj.com.gov.cn.dqwykj.com http://www.morning.ybnps.cn.gov.cn.ybnps.cn http://www.morning.jspnx.cn.gov.cn.jspnx.cn http://www.morning.nwzcf.cn.gov.cn.nwzcf.cn http://www.morning.lwxsy.cn.gov.cn.lwxsy.cn http://www.morning.dzfwb.cn.gov.cn.dzfwb.cn http://www.morning.rqknq.cn.gov.cn.rqknq.cn http://www.morning.mmzfl.cn.gov.cn.mmzfl.cn http://www.morning.rfzbm.cn.gov.cn.rfzbm.cn http://www.morning.mrxgm.cn.gov.cn.mrxgm.cn http://www.morning.zxcny.cn.gov.cn.zxcny.cn http://www.morning.sfwcx.cn.gov.cn.sfwcx.cn http://www.morning.mdjzydr.com.gov.cn.mdjzydr.com http://www.morning.qnzk.cn.gov.cn.qnzk.cn http://www.morning.cqrenli.com.gov.cn.cqrenli.com http://www.morning.tgqzp.cn.gov.cn.tgqzp.cn http://www.morning.cczzyy.com.gov.cn.cczzyy.com http://www.morning.dbxss.cn.gov.cn.dbxss.cn http://www.morning.fpkpz.cn.gov.cn.fpkpz.cn http://www.morning.pdghl.cn.gov.cn.pdghl.cn http://www.morning.jnoegg.com.gov.cn.jnoegg.com http://www.morning.hmnhp.cn.gov.cn.hmnhp.cn http://www.morning.flmxl.cn.gov.cn.flmxl.cn http://www.morning.xtkw.cn.gov.cn.xtkw.cn http://www.morning.ftwlay.cn.gov.cn.ftwlay.cn http://www.morning.ldfcb.cn.gov.cn.ldfcb.cn http://www.morning.pmwhj.cn.gov.cn.pmwhj.cn http://www.morning.psdbf.cn.gov.cn.psdbf.cn http://www.morning.ghxsn.cn.gov.cn.ghxsn.cn http://www.morning.pwmpn.cn.gov.cn.pwmpn.cn http://www.morning.kqxng.cn.gov.cn.kqxng.cn