map使用示例

#include<map>
#include<iostream>
#include <string>
using namespace std;
map<int,string>m;
int main(){
	m[1]="111";
	m[2]="222";
	map<int,string>::iterator m_i;
	m_i=m.find(1);
	if(m_i!=m.end()){
		cout<<m_i->second<<endl;
		cout<<m[1]<<endl;
	}
	m.erase(m_i);
	m_i=m.find(1);
	if(m_i==m.end()){
		cout<<"没找到\n";
	}
	
	return 0;
}

  

 

posted @ 2019-03-12 15:24  郑御前  阅读(132)  评论(0编辑  收藏  举报