C++ Primer 练习11.3.5

11.31 & 11.32:

#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<utility>
#include<algorithm>
using namespace std;

inline void print(multimap<string, string> cata)
{
	for (auto m : cata)
		cout << m.first << " " << m.second << endl;
}
int main(int argc, char* argv[])
{
	multimap<string, string> cata = {
		{"dzx","game"},
		{"zxg","love"},
		{"fly","friend"},
		{"dzx","code"},
		{"dzx","student"},
	};
	print(cata);
	cout << endl;

	string find_member = "zx";
	if (cata.find(find_member) != cata.end()) {
		cata.erase(find_member);
		cout << "Delete complete." << endl;
	}
	else
		cout << "I can't find." << endl;
	print(cata);
	return 0;
}

猜你喜欢

转载自blog.csdn.net/Dzx1025/article/details/107187764
今日推荐