PROGRAMMING LANGUAGE/C++
std::map
JC0
2021. 12. 24. 21:07
#include <iostream>
#include <map>
#include <algorithm>
using namespace std;
int main()
{
map< int, int> mp1;
mp1.insert(map<int, int>::value_type(1,2));
mp1.insert(map<int, int>::value_type(2, 5));
mp1.insert(map<int, int>::value_type(3, 7));
mp1[6] = 11;
mp1[7] = 21;
mp1[3] = 8;
mp1[5] = 4;
map<int, int> mp2;
mp2[8] = 3;
mp2[9] = 10;
mp1.insert(mp2.begin(), mp2.end());
for (auto itr = mp1.begin(); itr != mp1.end(); ++itr)
{
cout << itr->first << " " << itr->second << std::endl;
}
return 0;
}