/** =====================================================================================** Filename: for.cpp** Description:** Version: 1.0* Created: 2015年06月19日 11:01:17* Revision: none* Compiler: gcc** Author: zt (),* Organization:** =====================================================================================*/#include <stdio.h>#include <stdlib.h>#include <stdint.h>#include <vector>#include <iostream>#include <map>using namespace std;std::map<int, int> a ={{1, 100},#if 0{2, 200},{3, 300},{4, 400},{9, 400},#endif};int arr[] ={ 2, 1, 4, 5, 5, 6};std::vector<int> vec = { 1, 2 };int main ( int argc, char* argv[] ){( void ) argc;( void ) argv;auto iter2 = a.begin();for ( auto iter = a.begin(); iter != a.end(); ){printf ( "size=%zu ", a.size() );if ( iter->first == 1 )iter2 = a.erase ( iter++ );else++iter;printf ( "size=%zu ", a.size() );}iter2 = a.begin();printf ( "second =%d \n", iter2->second );printf ( "second =%d \n", iter2->second );printf ( "second =%d \n", iter2->second );for ( auto ele : a ){printf ( "%d\n", ele.first );}#if 0for ( auto& ele : a ){printf ( "| %d %d | %ld\n", ele.first, ele.second, a.size() );if ( ele.first == 1 )a.erase ( ele.first );//a.insert ( std::pair<int, int> ( 9, 250 ) );}printf ( "\n" );#endif#if 0for ( auto ele : vec ){printf ( "%d\n", ele );}auto& b = a;for ( const auto& ele : b ){if ( ele.first == 3 )b.erase ( ele.first );printf ( "size=%ld\n", b.size() );}for ( const auto& ele : a ){printf ( "| %d %d | ", ele.first, ele.second );}printf ( "\n" );#endif#if 0for ( const auto& ele : a ){printf ( "| %d %d | ", ele.first, ele.second );}printf ( "\n" );for ( auto i : arr ){printf ( " %d ", i );}printf ( "\n" );#endifreturn 0;}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。