📄 maptest.cpp
字号:
// mapTest.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <map>
#include <string>
#include <algorithm>
#include "iostream"
using namespace std;
typedef map<string,int> strMap;
int main(int argc, char* argv[])
{
strMap mapTest;
mapTest[string("jjhou")]=0;
mapTest[string("Jerry")]=1;
mapTest[string("jason")]=2;
pair<string,int>value(string("david"),3);
mapTest.insert(value);
strMap::iterator it=mapTest.begin();
for (;it!=mapTest.end();it++)
{
cout<<it->first<<' '<<it->second<<endl;
}
//实现元素的查找
strMap::iterator itel;
itel=mapTest.find(string("mchen"));
if (itel==mapTest.end())
{
cout<<"mchen not found"<<endl;
}
itel=mapTest.find(string("Jerry"));
if(itel!=mapTest.end())
{
cout<<"jerry found"<<endl;
}
itel->second=9;
cout<<"The jerry= "<<itel->second<<endl;
printf("Hello World!\n");
return 0;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -