代码拉取完成,页面将自动刷新
/*
* Copyright (c) JoinQuant Development Team
* Author: Huayong Kuang <kuanghuayong@joinquant.com>
*/
#include <iostream>
#include <unordered_map>
using namespace std;
typedef unordered_map<int, int> uo_map_t;
string check_key(uo_map_t m, int key)
{
// Key is not present
if (m.find(key) == m.end())
return "Not Present";
return "Present";
}
int main()
{
uo_map_t m;
// Initializing keys and mapped values
m[1] = 4;
m[2] = 6;
m[4] = 6;
// Keys to be checked
int check1 = 5, check2 = 4;
// Function call
cout << check1 << ": " << check_key(m, check1) << endl;
cout << check2 << ": " << check_key(m, check2) << endl;
int t = m[10];
cout << "try get value from map: " << t << endl;
int t2 = m.at(20);
cout << "at 20: " << t2 << endl;
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。