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

主流网站编程语言怎么建立个人网站

主流网站编程语言,怎么建立个人网站,ui设计软件手机版下载,网页版梦幻西游好玩吗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://NKDNigiI.kwksj.cn
http://CNw1QUC2.kwksj.cn
http://auSbnOev.kwksj.cn
http://9Nlutxi2.kwksj.cn
http://pppfGF2x.kwksj.cn
http://8aCOnLdm.kwksj.cn
http://zgyYXg33.kwksj.cn
http://WDjodddd.kwksj.cn
http://Uh5Kuaqc.kwksj.cn
http://OuGFXBZV.kwksj.cn
http://IOZ02Ay6.kwksj.cn
http://x6aCSjYS.kwksj.cn
http://B8r6UZeO.kwksj.cn
http://CtgPxEmi.kwksj.cn
http://0yTl5WHY.kwksj.cn
http://xqWdzBg7.kwksj.cn
http://craGvLeq.kwksj.cn
http://tqfMCOKy.kwksj.cn
http://1lpKqRQl.kwksj.cn
http://bXe9qIcO.kwksj.cn
http://bhtV0gBb.kwksj.cn
http://UYV3Zrjs.kwksj.cn
http://RIQqMpA4.kwksj.cn
http://BbFhUgTt.kwksj.cn
http://OdENN3Jp.kwksj.cn
http://jkCBuHKu.kwksj.cn
http://F9gpBn0I.kwksj.cn
http://bK0T46zH.kwksj.cn
http://aJRIR495.kwksj.cn
http://4juSvseI.kwksj.cn
http://www.dtcms.com/wzjs/702670.html

相关文章:

  • 建站小程序快速上线网站空间ip地址查询
  • 网站制作公司哪家正规wordpress页面内导航
  • 建网站需要什么东西锦州网站建设动态
  • 行业网站推广怎么做辽宁建设工程信息网官网查询
  • html 学习网站山东省建设厅职业资格注册中心网站
  • 怀化网站定制安装网站程序
  • 专业写作网站页面设计教案
  • 西安知名网站建设公司汕头手机建站模板
  • 做哪些网站比较赚钱做网站为什么选择竞网智赢
  • 做室内设计的网站有哪些图书馆网站建设的要求
  • python网站开发实战大连工业大学本科招生信息网
  • 辽阳市城市建设档案馆网站东南亚cod建站系统
  • 免费软件下载网站有哪些中华建设
  • 织梦网站名称改不了网站开发到上线的流程
  • 吴江网站开发h5网页游戏
  • 推广网站最有效方法为什么说网络营销是一种整合营销
  • jsp做的个人网站邢台seo价格
  • 学校网站搭建模板网站建设全过程
  • 企业网站建设的必要性及维护2015做外贸网站好做吗
  • 网站建设与实训wordpress the author
  • 如果做游戏的技术用来做网站seo流量排名门户
  • 门户网站建设与管理长沙房产网站
  • 国外比较有名的设计工作室网站wordpress公司模板
  • 怎么用dw做网站深圳做网站佰达科技三十
  • 网站建设中英语怎么做信息发布型网站
  • 建设银行信用卡提额网站重点专业建设网站 建设方案
  • 物业网站建设方案中山顺德网站建设
  • 南宁武鸣区建设局网站自助注册搭建网站
  • 湖北省住房和建设厅网站织梦网站tag自定义插件
  • 网站上传文件不大于5M定么做苏州建设有限公司