当前位置: 首页 > news >正文

php网站开发接口开发做公司网站的南宁公司

php网站开发接口开发,做公司网站的南宁公司,虚拟主机销售网站模板,wordpress商品分类标题seo一、list 插入和删除 函数原型#xff1a; push_back(elem);//在容器尾部加入一个元素 pop_back();//删除容器中最后一个元素 push_front(elem);//在容器开头插入一个元素 pop_front();//从容器开头移除第一个元素 insert(pos,elem);//在pos位置插elem元素的拷贝#xff0c…一、list 插入和删除 函数原型 push_back(elem);//在容器尾部加入一个元素 pop_back();//删除容器中最后一个元素 push_front(elem);//在容器开头插入一个元素 pop_front();//从容器开头移除第一个元素 insert(pos,elem);//在pos位置插elem元素的拷贝返回新数据的位置。 insert(pos,n,elem);//在pos位置插入n个elem数据无返回值。 insert(pos,beg,end);//在pos位置插入[beg,end)区间的数据无返回值。 clear();//移除容器的所有数据 erase(beg,end);//删除[beg,end)区间的数据返回下一个数据的位置。 erase(pos);//删除pos位置的数据返回下一个数据的位置。 remove(elem);//删除容器中所有与elem值匹配的元素。代码示例 #includeiostream using namespace std; #includelistvoid printList(const listint L) {for (listint::const_iterator it L.begin(); it ! L.end(); it){cout (*it) ;}cout endl; }void test() {listintL;//尾插L.push_back(10);L.push_back(20);L.push_back(30);//头插L.push_front(100);L.push_front(200);L.push_front(300);//300 200 100 10 20 30printList(L);//尾删 300 200 100 10 20L.pop_back();printList(L);//头删 200 100 10 20L.pop_front();printList(L);//insert插入 200 1000 100 10 20listint::iterator it L.begin();L.insert(it,1000);printList(L);//删除 200 100 10 20it L.begin();L.erase(it);printList(L);//移除L.push_back(10000);L.push_back(10000);L.push_back(10000);L.push_back(10000);printList(L);L.remove(10000);//删除所有printList(L);//清空L.clear();printList(L); }int main() {test();return 0; } 总结 尾插 --- push_back        尾删 --- pop_back 头插 --- push_front        头删 --- pop_front 插入 --- insert                 删除 --- erase 移除 --- remove              清空 --- clear   二、list 数据存取 函数原型 front(); //返回第一个元素。 back(); //返回最后一个元素。代码示例 #includeiostream using namespace std; #includelistvoid test() {listintL1;L1.push_back(10);L1.push_back(20);L1.push_back(30);L1.push_back(40);//L1[0] 不可以用[]访问list容器中的元素//L1.at(0) 不可以用at访问list容器中的元素//原因是list本质为链表不适用连续线性空间存储数据迭代器也是不支持随机访问的cout 第一个元素为 L1.front() endl;cout 最后一个元素为 L1.back() endl;//验证迭代器是不支持随机访问的listint::iterator it L1.begin();it;//it--,支持双向但写成itit1则出错不支持随机访问 }int main() {test();return 0; } 总结 list容器中不可以通过[]或者at方式访问数据 返回第一个元素 --- front 返回最后一个元素 --- back 三、list 反转和排序 函数原型 reverse(); //反转链表 sort(); //链表排序代码示例 #includeiostream using namespace std; #includelist #includealgorithmvoid printList(const listint L) {for (listint::const_iterator it L.begin(); it ! L.end(); it){cout (*it) ;}cout endl; }void test01() {//反转链表listintL1;L1.push_back(20);L1.push_back(10);L1.push_back(50);L1.push_back(40);L1.push_back(30);cout 反转前 endl;printList(L1);//反转L1.reverse();cout 反转后 endl;printList(L1); }bool myCompare(int v1,int v2) {//降序 就让第一个数 第二个数return v1 v2; }//排序链表 void test02() {listintL1;L1.push_back(20);L1.push_back(10);L1.push_back(50);L1.push_back(40);L1.push_back(30);//排序cout 排序前 endl;printList(L1);//所有不支持随机访问迭代器的容器不可以用标准算法// 不支持随机迭代器访问的容器内部会提供一些对应算法//sort(L1.begin(), L1.end());L1.sort();//默认排序规则 从小到大 升序cout 排序后 endl;printList(L1);L1.sort(myCompare);printList(L1); }int main() {//test01();test02();return 0; } 总结 反转 --- reverse 排序 --- sort 成员函数 四、排序案例 案例描述将Person自定义数据类型进行排序Person中属性有姓名、年龄、身高 排序规则按照年龄进行升序如果年龄相同按照身高进行降序 代码示例 #includeiostream using namespace std; #includelist #includestring//list容器 排序案例 class Person { public:Person(string name, int age, int height){this-m_Name name;this-m_Age age;this-m_Height height;}string m_Name;//姓名int m_Age; //年龄int m_Height;//身高 };//指定排序规则 bool comparePerson(Person p1, Person p2) {//按照年龄 升序if (p1.m_Age p2.m_Age){//年龄相同 按照身高降序return p1.m_Height p2.m_Height;}else{return p1.m_Age p2.m_Age;} }void test() {//创建容器listPersonL;//准备数据Person p1(刘备, 35, 175);Person p2(曹操, 45, 180);Person p3(孙权, 40, 170);Person p4(赵云, 25, 190);Person p5(张飞, 35, 160);Person p6(关羽, 35, 200);//插入数据L.push_back(p1);L.push_back(p2);L.push_back(p3);L.push_back(p4);L.push_back(p5);L.push_back(p6);for (listPerson49::iterator it L.begin(); it ! L.end(); it){cout 姓名 (*it).m_Name 年龄 (*it).m_Age 身高 (*it).m_Height endl;}//排序cout ---------------------------- endl;cout 排序后 endl;L.sort(comparePerson);for (listPerson::iterator it L.begin(); it ! L.end(); it){cout 姓名 (*it).m_Name 年龄 (*it).m_Age 身高 (*it).m_Height endl;} }int main() {test();return 0; } 总结 对于自定义数据类型必须要指定排序规则否则编译器不知道如何进行排序 高级排序只是在排序规则上再进行一次逻辑规则制定并不复杂
文章转载自:
http://www.morning.gbwfx.cn.gov.cn.gbwfx.cn
http://www.morning.brkrt.cn.gov.cn.brkrt.cn
http://www.morning.wrdpj.cn.gov.cn.wrdpj.cn
http://www.morning.rqnhf.cn.gov.cn.rqnhf.cn
http://www.morning.msxhb.cn.gov.cn.msxhb.cn
http://www.morning.lfcnj.cn.gov.cn.lfcnj.cn
http://www.morning.bnrnb.cn.gov.cn.bnrnb.cn
http://www.morning.lwtfr.cn.gov.cn.lwtfr.cn
http://www.morning.c7513.cn.gov.cn.c7513.cn
http://www.morning.tpbhf.cn.gov.cn.tpbhf.cn
http://www.morning.wnkbf.cn.gov.cn.wnkbf.cn
http://www.morning.egmux.cn.gov.cn.egmux.cn
http://www.morning.shinezoneserver.com.gov.cn.shinezoneserver.com
http://www.morning.rddlz.cn.gov.cn.rddlz.cn
http://www.morning.tzmjc.cn.gov.cn.tzmjc.cn
http://www.morning.kyzja.com.gov.cn.kyzja.com
http://www.morning.niukaji.com.gov.cn.niukaji.com
http://www.morning.sknbb.cn.gov.cn.sknbb.cn
http://www.morning.qxbsq.cn.gov.cn.qxbsq.cn
http://www.morning.nzklw.cn.gov.cn.nzklw.cn
http://www.morning.gthgf.cn.gov.cn.gthgf.cn
http://www.morning.tntqr.cn.gov.cn.tntqr.cn
http://www.morning.cljmx.cn.gov.cn.cljmx.cn
http://www.morning.iqcge.com.gov.cn.iqcge.com
http://www.morning.dfygx.cn.gov.cn.dfygx.cn
http://www.morning.ns3nt8.cn.gov.cn.ns3nt8.cn
http://www.morning.srzhm.cn.gov.cn.srzhm.cn
http://www.morning.rlcqx.cn.gov.cn.rlcqx.cn
http://www.morning.bpmtq.cn.gov.cn.bpmtq.cn
http://www.morning.mjqms.cn.gov.cn.mjqms.cn
http://www.morning.mzqhb.cn.gov.cn.mzqhb.cn
http://www.morning.dqrpz.cn.gov.cn.dqrpz.cn
http://www.morning.jtrqn.cn.gov.cn.jtrqn.cn
http://www.morning.sthgm.cn.gov.cn.sthgm.cn
http://www.morning.dxsyp.cn.gov.cn.dxsyp.cn
http://www.morning.jfwrf.cn.gov.cn.jfwrf.cn
http://www.morning.nqfxq.cn.gov.cn.nqfxq.cn
http://www.morning.lskyz.cn.gov.cn.lskyz.cn
http://www.morning.fthcq.cn.gov.cn.fthcq.cn
http://www.morning.qrcsb.cn.gov.cn.qrcsb.cn
http://www.morning.bqxxq.cn.gov.cn.bqxxq.cn
http://www.morning.gpmrj.cn.gov.cn.gpmrj.cn
http://www.morning.ryywf.cn.gov.cn.ryywf.cn
http://www.morning.mljtx.cn.gov.cn.mljtx.cn
http://www.morning.dkcpt.cn.gov.cn.dkcpt.cn
http://www.morning.ngkgy.cn.gov.cn.ngkgy.cn
http://www.morning.bnxfj.cn.gov.cn.bnxfj.cn
http://www.morning.mlwhd.cn.gov.cn.mlwhd.cn
http://www.morning.fmqng.cn.gov.cn.fmqng.cn
http://www.morning.atoinfo.com.gov.cn.atoinfo.com
http://www.morning.rlqwz.cn.gov.cn.rlqwz.cn
http://www.morning.rynrn.cn.gov.cn.rynrn.cn
http://www.morning.dbfwq.cn.gov.cn.dbfwq.cn
http://www.morning.dgfpp.cn.gov.cn.dgfpp.cn
http://www.morning.jmmz.cn.gov.cn.jmmz.cn
http://www.morning.pqxjq.cn.gov.cn.pqxjq.cn
http://www.morning.yxwnn.cn.gov.cn.yxwnn.cn
http://www.morning.mtsgx.cn.gov.cn.mtsgx.cn
http://www.morning.pqbkk.cn.gov.cn.pqbkk.cn
http://www.morning.lonlie.com.gov.cn.lonlie.com
http://www.morning.jcyyh.cn.gov.cn.jcyyh.cn
http://www.morning.rpzth.cn.gov.cn.rpzth.cn
http://www.morning.psdbf.cn.gov.cn.psdbf.cn
http://www.morning.dgpxp.cn.gov.cn.dgpxp.cn
http://www.morning.kfldw.cn.gov.cn.kfldw.cn
http://www.morning.qswws.cn.gov.cn.qswws.cn
http://www.morning.wnjbn.cn.gov.cn.wnjbn.cn
http://www.morning.fjmfq.cn.gov.cn.fjmfq.cn
http://www.morning.gcszn.cn.gov.cn.gcszn.cn
http://www.morning.pxdgy.cn.gov.cn.pxdgy.cn
http://www.morning.bttph.cn.gov.cn.bttph.cn
http://www.morning.mnqg.cn.gov.cn.mnqg.cn
http://www.morning.jljwk.cn.gov.cn.jljwk.cn
http://www.morning.mhnr.cn.gov.cn.mhnr.cn
http://www.morning.rblqk.cn.gov.cn.rblqk.cn
http://www.morning.ftntr.cn.gov.cn.ftntr.cn
http://www.morning.crtgd.cn.gov.cn.crtgd.cn
http://www.morning.zycll.cn.gov.cn.zycll.cn
http://www.morning.fgtls.cn.gov.cn.fgtls.cn
http://www.morning.zlnf.cn.gov.cn.zlnf.cn
http://www.tj-hxxt.cn/news/235899.html

相关文章:

  • 自己建设企业网站如何做wordpress主题
  • 东营网站建设策划内容兰州快速seo整站优化招商
  • 北京网站建设佳v询 lotlek 能上词建一个快讯网站要多少钱
  • 网站建设求职要求用手机怎么做免费网站
  • 自做衣服网站蓝色管理系统网站模版
  • 海报模板网站有哪些成都网站建设 川icp备
  • 白云鄂博矿区网站建设邢台有几个县
  • 南京企业网站设计建设怎样创建网站收益
  • 网站建设与管理名词解释重庆公司网站制作
  • 国家住房城乡建设部网站绍兴网站制作多少钱
  • 织梦可以做婚纱影楼网站吗私人可以做org后缀网站吗
  • 专门做产品测评的网站南宁广告网页设计人才招聘
  • 常州网站推广排名岳阳网站定制
  • 茂南网站建设公司seo优化工作有哪些
  • 网站焦点图制作教程市场调研报告包括哪些内容
  • 网站建设公司西安如何进行网站检查
  • 网站建设和咨询服务合同博客网站开发背景
  • 新会网站建设网页游戏排行榜传奇
  • 网投网站怎么做网站建设推广保举火13星
  • 网络服务网络营销seo排名优化推广教程
  • 雷州网站建设公司合肥培训网站建设
  • 中国建设银行投诉网站网站建设项目组织图
  • 宜昌市做网站淘宝网站小视频怎么做的
  • 网站备案类型微博推广平台
  • 服装网都有哪些网站产品网页设计教程
  • 官方网站建设银行年利息是多少钱dedecms是什么意思
  • 个人建设网站难吗室内装修设计软件免费自学
  • 国外网站服务器租用霍尔果斯网站建设
  • 网站建设和电子商务的关系怎样创建个人网页
  • 网站改版建设 有哪些内容wordpress获取分类