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

百度爱采购怎样入驻查询seo

百度爱采购怎样入驻,查询seo,郑州做网站的多不多,上海的网站开发公司电话1.概念 map中所有元素都是pair<key,value>&#xff0c;key 是map的键&#xff0c;value 是map的值 所有元素都会根据key自动排序 map/multimap属于关联式容器&#xff0c;底层结构是用二叉树实现。 map和multimap区别&#xff1a; map不允许容器中有重复key值元素 m…

1.概念

map中所有元素都是pair<key,value>,key 是map的键,value 是map的值

所有元素都会根据key自动排序

map/multimap属于关联式容器,底层结构是用二叉树实现。

map和multimap区别

  • map不允许容器中有重复key值元素

  • multimap允许容器中有重复key值元素

2.map构造和赋值

map<T1,T2> mp;

map(const map &mp);// 拷贝构造

map &operator=(const map &mp);

#include <iostream>
#include <map>using namespace std;void printMap(const map<int,int> &mp)
{for(map<int,int>::const_iterator it = mp.begin(); it != mp.end(); it++){cout << "key = " << it->first << " value = " << it->second << endl;}cout<<endl;
}void test(){map<int,int> m;m.insert(pair<int,int>(1,10));m.insert(pair<int,int>(2,20));m.insert(pair<int,int>(3,30));printMap(m);map<int,int>m2(m);// 拷贝构造printMap(m2);map<int,int>m3;m3 = m2;// 赋值printMap(m3);}int main()
{test();system("pause");return 0;
}

3.map大小和交换

#include <iostream>
#include <map>using namespace std;void printMap(map<int, int> &m){for (map<int, int>::iterator it = m.begin(); it != m.end(); it++){cout << "key = " << it->first << " value = " << it->second << endl;}cout<<endl;
}
void test(){map<int,int> m;m.insert(pair<int,int>(1,10));m.insert(pair<int,int>(2,20));m.insert(pair<int,int>(3,30));if (m.empty()){cout<<"map为空"<<endl;}else{cout<<"map不为空"<<endl;cout<<"map的大小为:"<<m.size()<<endl;}map<int,int>m2(m);map<int,int>m3;m3.insert(pair<int,int>(4,40));m3.insert(pair<int,int>(5,50));m3.insert(pair<int,int>(6,60));m3.swap(m2);printMap(m3);}int main()
{test();system("pause");return 0;
}

4.map插入和删除

insert(elem);

clear();

erase(pos);// 删除pos位置的元素,返回删除元素的下一个位置

erase(beg,end);// 删除beg到end之间的元素,左闭右开

erase(key);// 删除key对应的元素

#include <iostream>
#include <map>using namespace std;void printMap(const map<int,int> &m){for(map<int,int>::const_iterator it=m.begin();it!=m.end();it++){cout<<it->first<<" "<<it->second<<endl;}cout<<endl;
}void test(){map<int,int> m;m.insert(pair<int,int>(1,10));m.insert(make_pair(2,20));m.insert(map<int,int>::value_type(3,30));m[4]=40;printMap(m);//删除m.erase(m.begin());printMap(m);m.erase(3);printMap(m);//清空m.clear();m.erase(m.begin(),m.end());printMap(m);
}int main()
{test();system("pause");return 0;
}

5. map查找和统计

find(key);// 查找key对应的value,不存在返回end()

count(key);// 统计key出现的次数

#include <iostream>
#include <map>using namespace std;void printMap(map<int, int> &m)
{for (map<int, int>::iterator it = m.begin(); it != m.end(); it++){cout << "key = " << it->first << " value = " << it->second << endl;}cout<<endl;
}void test(){map<int, int>m; m.insert(pair<int, int>(1, 10));m.insert(pair<int, int>(2, 20));m.insert(pair<int, int>(3, 30));auto pos=m.find(3);// auto自动推导迭代器类型if(pos!=m.end()){cout<<"key = "<<pos->first<<" value = "<<pos->second<<endl;}else{cout<<"没有找到key = 3"<<endl;}int num=m.count(1);cout<<"key = 1 出现的次数 = "<<num<<endl;
}int main()
{test();system("pause");return 0;
}

 6. map容器排序

map容器默认排序规则为 按照key值进行 从小到大排序

#include <iostream>
#include <map>using namespace std;class MyCompare{public:bool operator()(int v1,int v2) const{return v1>v2;}
};void test(){map<int, int, MyCompare> m;m.insert(make_pair(1, 10));m.insert(make_pair(2, 20));m.insert(make_pair(3, 30));m.insert(make_pair(4, 40));m.insert(make_pair(5, 50));for (map<int, int,MyCompare>::const_iterator it = m.begin(); it != m.end(); it++){cout << "key = " << it->first << " value = " << it->second << endl;}
}int main()
{test();system("pause");return 0;
}

http://www.dtcms.com/wzjs/367662.html

相关文章:

  • 网站文字大小代码长沙seo关键词排名优化
  • 方微商城网站开发策划
  • 一流的菏泽网站建设百度旧版本
  • 网站服务器租用时间网上营销推广
  • 义乌做网站的电话图片搜索识图入口
  • 仿糗事百科wordpress怎么学seo基础
  • wordpress 美图主题seo关键字优化技巧
  • 绘画网站建设如何让百度收录自己的网站信息
  • 北海 做网站 英文数字营销网站
  • 安装wordpress it works灵宝seo公司
  • 微信小程序怎么做网站免费涨1000粉丝网站
  • 专做婚宴用酒是网站网络营销的认知
  • 将html和wordpress分开seo入门教程网盘
  • 建行官网网站p站关键词排名
  • 学做家庭树网站无锡百度推广代理商
  • asp.net做的网站模板如何在百度提交网站
  • 有没有做ppt很厉害的网站seo 视频
  • 花生壳内网穿透网站如何做seo优化网络营销软件商城
  • 模板网站价格表他达拉非片正确服用方法
  • 如何用ps做网站标识东莞营销网站建设直播
  • 企业网站管理系统介绍百度竞价最低点击一次多少钱
  • 一定火网站建设定制深圳百度快照优化
  • 北京网站设计公司哪儿济南兴田德润简介百度优化服务
  • 做模板网站乐云seo效果好如何制作一个网页
  • 江苏建设纸质考试网站免费推广网站推荐
  • 12306网站如何做火车票候补百度收录规则2022
  • 网站开发如何运用form表单如何引流推广产品
  • 网站建设 指标自己做网站如何赚钱
  • 做编程题的网站百度人工客服电话是多少
  • 如何判断一个网站的关键词是否难做东莞百度推广优化排名