#include<iostream>
#include<string>
#include<unordered_map>
using namespace std;
int main()
{
unordered_map<string, int> hm;
hm["BILL"] = 100;
hm["TOM"] = 90;
hm["JAMES"] = 88;
hm["JERRY"] = 77;
cout << hm["TOM"] << endl;
//查找 key = x 是否存在map中
if (hm.find("TOM") != hm.end()) cout << 1 << endl;
//统计 key = x
if (hm.count("TOM") != 0) cout << 1 << endl;
cin.get();
return 0;
}
哈希表的建立与查找
最新推荐文章于 2023-04-10 17:39:28 发布