zoukankan      html  css  js  c++  java
  • ma'p'ma'p'ma'p

    #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;
    }
    
  • 相关阅读:
    importToMbtiles
    http-server服务跨域设置
    Leaflet 测试加载高德地图
    矢量切片
    zigzag方式编码
    CentOS7安装docker
    CentOS7安装NodeJS
    CentOS7上Python3.5安装
    JDK8下maven使用maven-javadoc-plugin插件报错
    Ubuntu16.10上安装NodeJS6.9.2
  • 原文地址:https://www.cnblogs.com/shenxiaodou/p/12597455.html
Copyright © 2011-2022 走看看