C++: Insertion des valeurs paires dans un map

Author:

 map, iterator
{filelink=15027}


#include 
using namespace  std;
#include


int main()
{
   map< int, double> pairs;

   pairs.insert( map< int, double>::value_type( 20, 3.17 ) );
   pairs.insert( map< int, double>::value_type( 05, 14.34 ) );
   pairs.insert( map< int, double>::value_type( 30, 2036 ) );
   pairs.insert( map< int, double>::value_type( 10, 33.33 ) );
   pairs.insert( map< int, double>::value_type( 25, 14.250 ) );
   pairs.insert( map< int, double>::value_type( 0,  3.14 ) );

   cout << "Contenu: n";

   for ( map< int, double>::const_iterator iter = pairs.begin();
      iter != pairs.end(); ++iter )
      cout << iter->first << '	' << iter->second << 'n';

   cout << endl;
   return 0;
}
/*
Contenu:
0       3.14
5       14.34
10      33.33
20      3.17
25      14.25
30      2036

Press any key to continue
*/

Leave a Reply

Your email address will not be published. Required fields are marked *