首页 > 其他 > 详细

ma'p'ma'p'ma'p

时间:2020-03-30 12:23:05      阅读:73      评论:0      收藏:0      [点我收藏+]
#include<map>
#include<iostream>

using namespace std;

int main()
{
			map <int, int> m1, m2, m3;//定义仨map 
			map <int,int>::iterator m1_Iter; //map迭代器 
			
			m1.insert( pair <int, int>(1, 60 ) );
			 m1.insert( pair <int, int>(1, 50 ) );
			m1.insert ( pair <int,int> ( 2, 20 ) );
			m1.insert ( pair <int,int> ( 3, 30 ) );
			m2.insert ( pair <int,int> ( 10, 100 ) );
			m2.insert ( pair <int,int> ( 20, 200 ) );
			m3.insert ( pair <int,int> ( 30, 300 ) );
			 	map<int,int>::iterator  it; 
//			it=m1.find(2 );
//		    if(it!=m1.end())
//		    {cout<<"123456";m1.erase(it);}
			cout << "The original map m1is:";
			for ( m1_Iter = m1.begin( ) ; m1_Iter != m1.end() ; m1_Iter++ )
			cout << " "<<m1_Iter->second;
			cout << "."<< endl;
			cout<<m1[2];
			
		// (key,value)
		
			
			// This isthe member function version of swap
			// m2 is said to be theargument map; m1 the target map
//			m1.swap( m2);
//			
//			cout << "Afterswapping with m2, map m1 is:";
//			for ( m1_Iter = m1.begin( ) ; m1_Iter != m1.end() ; m1_Iter++ )
//			mapmapmapcout << " "<< m1_Iter ->second;
//			cout << "."<< endl;
//			
//			
//			cout << "After swapping with m2, mapm2 is:";
//			for ( m1_Iter = m2.begin( ); m1_Iter != m2.end(); m1_Iter++ )
//			cout << " "<< m1_Iter ->second;
//			cout << "."<< endl;
//			
//			
//			// This is the specialized template version of swap
//			swap( m1, m3 );
//			
//			cout << "Afterswapping with m3, map m1 is:";
//			for ( m1_Iter = m1.begin( ); m1_Iter != m1.end(); m1_Iter++ )
//			cout << " "<< m1_Iter ->second;
//			cout << "."<< endl;
}

ma'p'ma'p'ma'p

原文:https://www.cnblogs.com/shenxiaodou/p/12597455.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!