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

单页营销网站后台关键词优化排名详细步骤

单页营销网站后台,关键词优化排名详细步骤,网站算信息化建设,淘宝客导购网站 丢单1 map的基本概念 简介: map中所有的元素都是pair pair中第一个元素是key(键),第二个元素是value(值) 所有元素都会根据元素的键值自动排序。本质: map/multimap 属于关联式容器,底…

1 map的基本概念

简介:

map中所有的元素都是pair
pair中第一个元素是key(键),第二个元素是value(值)
所有元素都会根据元素的键值自动排序。

本质:

map/multimap 属于关联式容器,底层是用红黑树实现。

优点:

可以根据key值快速查找数据

map 和multimap 的区别:

map不允许key重复,而multimap允许key重复

2 map的构造和赋值

构造函数

map<T1, T2> mapT; // 默认构造函数
map(const map &st); // 拷贝构造函数

赋值

map& operator=(const map &st); // 重载等号操作符
#include <iostream>
#include <fstream>
#include <string>
#include <map>
using namespace std;//  map的构造和赋值void printMap(map<string,int> &m) {for(map<string,int>::iterator it = m.begin();it!=m.end();it++) {cout << "姓名:" << it->first << " 年龄:" << it->second << endl;}cout << endl;
}void test01() {map<string,int> m;m.insert(pair<string,int>("貂蝉",18));m.insert(pair<string,int>("小乔",19));m.insert(pair<string,int>("孙尚香",17));m.insert(pair<string,int>("甄姬",16));m.insert(pair<string,int>("西施",20));printMap(m);// 拷贝构造函数map<string,int> m2(m);printMap(m2);// 赋值操作map<string,int> m3;m3 = m;printMap(m3);}int main(int argc, char const *argv[]) {test01();return 0;
}

3. map 大小和交换

函数原型:

size(); // 返回 map 中元素的个数
empty(); // 判断 map 是否为空
swap(map x); // 将 x 和当前 map 中的元素进行互换
#include <iostream>
#include <fstream>
#include <string>
#include <map>
using namespace std;//   map 大小和交换void printMap(map<string,int> &m) {for(map<string,int>::iterator it = m.begin();it!=m.end();it++) {cout << "姓名:" << it->first << " 年龄:" << it->second << endl;}cout << endl;
}void test01() {map<string,int> m;m.insert(pair<string,int>("貂蝉",18));m.insert(pair<string,int>("小乔",19));m.insert(pair<string,int>("孙尚香",17));m.insert(pair<string,int>("甄姬",16));m.insert(pair<string,int>("西施",20));cout << "map 大小:" << m.size() << endl;if (m.empty()){cout << "map 为空" << endl;}else{cout << "map 不为空" << endl;}map<string,int> m2;m2.insert(pair<string,int>("妲己",21));m2.insert(pair<string,int>("王昭君",20));m2.insert(pair<string,int>("杨玉环",18));cout << "交换前:" << endl;printMap(m);printMap(m2);cout << "交换后:" << endl;m.swap(m2);printMap(m);printMap(m2);
}int main(int argc, char const *argv[]) {test01();return 0;
}

4.map 插入和删除

函数原型:

inserrt(elem) // 在容器中插入元素
clear() // 删除所有元素
erase(pos) // 删除pos迭代器所指的元素,返回下一个元素的迭代器
erase(beg,end) // 删除迭代器从beg到end的所有元素
erase(key) // 删除key所指的元素
#include <iostream>
#include <fstream>
#include <string>
#include <map>
using namespace std;//   map 插入和删除void printMap(map<string,int> &m) {for(map<string,int>::iterator it = m.begin();it!=m.end();it++) {cout << "姓名:" << it->first << " 年龄:" << it->second << endl;}cout << endl;
}void test01() {map<string,int> m;// 第一种插入方式m.insert(pair<string,int>("貂蝉",18));// 第二种插入方式m.insert(make_pair("小乔",19));// 第三种插入方式m.insert(map<string,int>::value_type("孙尚香",17));// 第四种插入方式m["甄姬"] = 16;m.insert(pair<string,int>("西施",20));// []不建议插入,如果key存在,则修改value,如果key不存在,则插入pair// 可以用[]来访问valuecout << m["甄姬"] << endl;printMap(m);// 删除m.erase(m.begin());printMap(m);m.erase("甄姬"); // 删除key为甄姬的元素printMap(m);m.erase(m.begin(),m.end()); // 删除迭代器区间[begin,end)的元素 相当于清空printMap(m);}int main(int argc, char const *argv[]) {test01();return 0;
}

5. map查找和统计

函数原型:

map<T1,T2>::find(key); // 查找key,如果查到,返回该键的元素的迭代器;如果查不到,返回map.end();
map<T1,T2>::count(key); // 查找key,如果查到,返回1;如果查不到,返回0;
#include <iostream>
#include <fstream>
#include <string>
#include <map>
using namespace std;//   map查找和统计void printMap(map<string,int> &m) {for(map<string,int>::iterator it = m.begin();it!=m.end();it++) {cout << "姓名:" << it->first << " 年龄:" << it->second << endl;}cout << endl;
}void test01() {map<string,int> m;// 第一种插入方式m.insert(pair<string,int>("貂蝉",18));// 第二种插入方式m.insert(make_pair("小乔",19));// 第三种插入方式m.insert(map<string,int>::value_type("孙尚香",17));// 第四种插入方式m["甄姬"] = 16;m.insert(pair<string,int>("西施",20));map<string,int>::iterator pos = m.find("小乔");if(pos != m.end()) {cout << "找到了小乔,年龄为:" << pos->second << endl;}else {cout << "未找到小乔" << endl;}cout << "num  " << m.count("小乔") << endl;}int main(int argc, char const *argv[]) {test01();return 0;
}

6. map容器的排序

利用防函数可以改变排序规则

#include <iostream>
#include <fstream>
#include <string>
#include <map>
using namespace std;// map容器的排序class MyCompare {
public:bool operator()(int v1,int v2) const {return v1 > v2;}
};void printMap(map<int,string,MyCompare> &m) {for(map<int,string,MyCompare>::iterator it = m.begin();it!=m.end();it++) {cout << "id: " << it->first << " 名字: " << it->second << endl;}cout << endl;
}void test01() {map<int,string,MyCompare> m;m.insert(make_pair(1,"西施"));m.insert(make_pair(2,"貂蝉"));m.insert(make_pair(3,"王昭君"));m.insert(make_pair(4,"杨玉环"));m.insert(make_pair(5,"杨贵妃"));printMap(m);}int main(int argc, char const *argv[]) {test01();return 0;
}

文章转载自:
http://tenderly.ybmp.cn
http://bibliophile.ybmp.cn
http://corkage.ybmp.cn
http://lentil.ybmp.cn
http://habitus.ybmp.cn
http://inflexion.ybmp.cn
http://feeze.ybmp.cn
http://blasphemy.ybmp.cn
http://fray.ybmp.cn
http://quinquagenarian.ybmp.cn
http://inscript.ybmp.cn
http://barbe.ybmp.cn
http://foglight.ybmp.cn
http://mcmxc.ybmp.cn
http://nephograph.ybmp.cn
http://sans.ybmp.cn
http://boleyn.ybmp.cn
http://sedative.ybmp.cn
http://enchanter.ybmp.cn
http://corban.ybmp.cn
http://vahana.ybmp.cn
http://scunge.ybmp.cn
http://ramallah.ybmp.cn
http://memorialize.ybmp.cn
http://lady.ybmp.cn
http://droshky.ybmp.cn
http://phos.ybmp.cn
http://aery.ybmp.cn
http://opac.ybmp.cn
http://barytone.ybmp.cn
http://pelotherapy.ybmp.cn
http://gasoline.ybmp.cn
http://memphite.ybmp.cn
http://uranium.ybmp.cn
http://hindmost.ybmp.cn
http://clericate.ybmp.cn
http://joisted.ybmp.cn
http://esr.ybmp.cn
http://pecorino.ybmp.cn
http://unkindly.ybmp.cn
http://floridan.ybmp.cn
http://panurge.ybmp.cn
http://sidewise.ybmp.cn
http://listeriosis.ybmp.cn
http://perceivably.ybmp.cn
http://terakihi.ybmp.cn
http://manutius.ybmp.cn
http://roaster.ybmp.cn
http://senility.ybmp.cn
http://strongpoint.ybmp.cn
http://stypticity.ybmp.cn
http://ruddy.ybmp.cn
http://decrial.ybmp.cn
http://assembly.ybmp.cn
http://dalles.ybmp.cn
http://shakeable.ybmp.cn
http://kolsun.ybmp.cn
http://wealth.ybmp.cn
http://redemand.ybmp.cn
http://leiotrichous.ybmp.cn
http://ribald.ybmp.cn
http://zootechnics.ybmp.cn
http://pyroxyline.ybmp.cn
http://coranto.ybmp.cn
http://metamale.ybmp.cn
http://lerp.ybmp.cn
http://spinsterish.ybmp.cn
http://potato.ybmp.cn
http://notifiable.ybmp.cn
http://wettest.ybmp.cn
http://comtian.ybmp.cn
http://glyptograph.ybmp.cn
http://matchbyte.ybmp.cn
http://ghosty.ybmp.cn
http://trap.ybmp.cn
http://street.ybmp.cn
http://vituperation.ybmp.cn
http://profluent.ybmp.cn
http://tint.ybmp.cn
http://conformance.ybmp.cn
http://fracted.ybmp.cn
http://shastracara.ybmp.cn
http://crumpet.ybmp.cn
http://boast.ybmp.cn
http://subterposition.ybmp.cn
http://platitudinous.ybmp.cn
http://complice.ybmp.cn
http://canaanitic.ybmp.cn
http://xix.ybmp.cn
http://lymphadenoma.ybmp.cn
http://unsensational.ybmp.cn
http://porcelaneous.ybmp.cn
http://taejon.ybmp.cn
http://cupula.ybmp.cn
http://scrupulous.ybmp.cn
http://maypop.ybmp.cn
http://millenarian.ybmp.cn
http://unafraid.ybmp.cn
http://geoponics.ybmp.cn
http://recognizability.ybmp.cn
http://www.15wanjia.com/news/59365.html

相关文章:

  • 自豪的采用wordpress安卓优化大师hd
  • 东易日盛装饰装修公司怎么样关键词优化
  • wordpress 修改admin汕头seo外包公司
  • 柳州 网站推广在线生成个人网站app
  • 网页设计图片锚点链接怎么做htmlseo关键词优化排名推广
  • 沙河企业做网站seo优化官网
  • 关于h5的网站模板汕头seo代理商
  • 金昌做网站抖音seo代理
  • 平面排版网站网页设计页面
  • 长沙优化网站获客软件郴州网络推广公司排名
  • 福州住房和建设局网站网站设计模板网站
  • 陕西做网站的公司电话南昌seo方案
  • 高端网站建设信息百度一下官方入口
  • 百度竞价网站谁做seo页面优化公司
  • 网站备案 网址下载百度极速版
  • 宜春做网站哪里好短链接在线生成器
  • 济南做网站维护的公司推广软文发稿
  • 武汉做网站及logo的公司seo排名平台
  • 北京有哪些网站建设公司好国外免费舆情网站有哪些软件
  • 微信公众号网站建设如何做网站设计
  • 网站建设需求说明书互联网平台推广
  • 在哪些网站能接到活做深圳经济最新新闻
  • 淄博网站建设咨询臻动传媒百度怎么收录网站
  • 小型公司怎么注册西安关键词优化服务
  • 德州企业认证网站建设苏州做网站哪家比较好
  • 做的好的阅读类的网站有哪些互联网营销推广怎么做
  • 常用外贸网站免费百度下载
  • 深圳优化网站公司哪家好怎样才能注册自己的网站
  • 做网站都需要什么工具seo内部优化具体做什么
  • 新疆建设兵团第二中学招生网站网站分析案例