stl中vecter和pair组合达到字典的效果

	typedef  std::pair  beanUnit;
	std::vector vec;
	vec.push_back(beanUnit("xuhaitao",36));
	vec.push_back(beanUnit("wangerxiao",63));
	vec.push_back(beanUnit("jidan", 25));
	vec.push_back(beanUnit("mao", 5));

	std::vector::iterator i = vec.begin();
	std::vector::iterator end = vec.end();



	while (i != end) {
		cout << i->first <second << endl;
		++i;
	}

stl中vecter和pair组合达到字典的效果_第1张图片

FR:hunkxu

你可能感兴趣的:(算法)