map查找统计
#include <iostream>
#include <map>
using namespace std;
int main()
{
map<int, string> m;
m.insert(pair<int, string>(1, "furong"));
m.insert(pair<int, string>(2, "quange"));
m.insert(pair<int, string>(3, "zhangsan"));
map<int, string>::iterator it = m.find(2);
if(it != m.end())
{
cout << it->first << ": " << it->second << endl;
}
int count = m.count(2);
cout << count << endl;
return 0;
}
$ ./a.out
2: quange
1