連想配列

プログラム例 5.4] 連想配列

/****************************/
/* 連想配列                 */
/*      coded by Y.Suganuma */
/****************************/
#include <iostream>
#include <map>
#include <string>

using namespace std;

int main()
{
	map<string, string> x ({{"red", "赤"}, {"blue", "青"}});
	x.insert(pair<string, string>("green", "緑"));
	cout << x.find("red")->second << endl;
	cout << x.find("blue")->second << endl;
	cout << x.find("green")->second << endl;
	for (auto a : x)
		cout << a.first << " は " << a.second << " です\n";
	return 0;
}