Digg StumbleUpon LinkedIn YouTube Flickr Facebook Twitter RSS Reset

C++: Insertion des valeurs paires dans un map

 map, iterator
{filelink=15027}

 
#include <iostream>
using namespace  std;
#include
<map>
 
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
*/

No comments yet.

Leave a Comment