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

网站建设公司汕头的重庆网搜科技有限公司

网站建设公司汕头的,重庆网搜科技有限公司,有哪些可以免费推广的平台,网站开发人员的岗位职责1、标准库的map类型 2、插入数据 #include <map> #include <string> #include <iostream>using namespace std;int main() {map<string, int> mapTest;// 插入到map容器内部的元素是默认按照key从小到大来排序// key类型一定要重载小于号<运算符map…

1、标准库的map类型

2、插入数据

#include <map>
#include <string>
#include <iostream>using namespace std;int main() {map<string, int> mapTest;// 插入到map容器内部的元素是默认按照key从小到大来排序// key类型一定要重载小于号<运算符mapTest["aaa"] = 100;  // int& operator[](const string& index);mapTest["eee"] = 500;  // 可以重新赋值,但是下面的用insert方法就不能重新赋值mapTest.insert(map<string, int>::value_type("bbb", 200));mapTest.insert(map<string, int>::value_type("bbb", 2000));mapTest.insert(pair<string, int>("ccc", 300));mapTest.insert(pair<string, int>("ccc", 3000));mapTest.insert(make_pair("ddd", 400));mapTest.insert(make_pair("ddd", 4000));map<string, int>::const_iterator it;for (it = mapTest.begin(); it != mapTest.end(); ++it){cout << it->first << " " << it->second << endl;}return 0;
}// 输出
aaa 100
bbb 200
ccc 300
ddd 400
eee 500

3、查找与修改

#include <map>
#include <string>
#include <iostream>using namespace std;int main() {map<string, int> mapTest;mapTest["aaa"] = 100;  // int& operator[](const string& index);mapTest.insert(map<string, int>::value_type("bbb", 200));mapTest.insert(pair<string, int>("ccc", 300));mapTest.insert(make_pair("ddd", 400));int n = mapTest["bbbc"];  // 这边如果找不到ket的值,还是会返回0,这样就不能判断有没有找到。所以得用限免的方式去查找cout << n << endl;mapTest["bbb"] = 2000;map<string, int>::iterator it;it = mapTest.find("ccc");if (it != mapTest.end()){it->second = 3000;}else{cout << "not found" << endl;}//    map<string, int>::const_iterator it;for (it = mapTest.begin(); it != mapTest.end(); ++it){cout << it->first << " " << it->second << endl;}return 0;
}// 输出
0
aaa 100
bbb 2000
bbbc 0
ccc 3000
ddd 400

4、删除

#include <map>
#include <string>
#include <iostream>using namespace std;int main() {map<string, int> mapTest;// 插入到map容器内部的元素是默认按照key从小到大来排序// key类型一定要重载小于号<运算符mapTest["aaa"] = 100;  // int& operator[](const string& index);mapTest.insert(map<string, int>::value_type("bbb", 200));mapTest.insert(pair<string, int>("ccc", 300));mapTest.insert(make_pair("ddd", 400));mapTest.erase("bbb");map<string, int>::const_iterator it;it = mapTest.find("ccc");if (it != mapTest.end()){mapTest.erase(it);}for (it = mapTest.begin(); it != mapTest.end(); ++it){cout << it->first << " " << it->second << endl;}return 0;
}// 输出
aaa 100
ddd 400

http://www.yayakq.cn/news/734552/

相关文章:

  • 网站建设中upl连接济南 网站建设 域名注册
  • 服务好的高端网站建设公司主页设计案例
  • 网站开发网站排名优化化妆品品牌策划方案
  • 详谈电商网站建设四大流程网站分类目录查询
  • 怎么黑掉织梦做的网站装饰设计有限公司经营范围
  • 建设网站一般要多钱响应式做的比较好的网站
  • 企业网站排版随州网站
  • 百度是网站吗数字营销网
  • 网站建设备案审核要多久erp系统的主要功能
  • 阿里云简单网站建设宁波做网站的企业
  • 华强方特网站开发网站的建设及维护报告
  • 珠海开发网站公司苏州园区人才市场
  • 网站新闻标题字数口碑好的郑州网站建设
  • 巴州住房和城乡建设局网站西安网站建设 招聘
  • 做平面设计在什么网站能挣钱沙田网站建设公司
  • 网站首页建设网网站建设合同 含维护费
  • 华安网站建设护肤品网站建设
  • 专业做网文的网站好企业为什么网站建设
  • 怎么才能让自己做的网站上传到百度搜关键字可以搜到wordpress登录锚点弹
  • wordpress公共函数在哪如何做网站seo韩小培
  • wordpress建站的教程广告设计效果图
  • 网站的建设期wordpress主题图片替换
  • 网页传奇网站关于产品网站建设的问题
  • 加油站项目建设背景门户网站什么意思
  • 网站开发字体的引用平面设计行业市场分析
  • 网站地址和网页地址做网站的画布是多少
  • 网站开发建设技术规范书做微商怎样加入网站卖东西赚钱
  • 福州企业网站开发南昌装修公司
  • 云服务器是否可以做多个网站网站建设500元
  • 网站开发找谁95资料库