#include <iostream>
#include <map>
using std::cout; using std::cin;
using std::endl; using std::map;
using std::string;
int main(){
string key_to_find;
std::map<string, string> lang_map = {{"j", "Julia",},
{"p", "Python",},
{"m", "MATLAB",},
{"o", "Octave",},
{"s", "Scala",},
{"l", "Lua",}};
for (const auto & [key, value] : lang_map) {
cout << key << " : " << value << endl;
}
cout << "Enter the key to search for: ";
cin >> key_to_find;
if (lang_map.find(key_to_find) != lang_map.end()) {
cout << "Key Exists!" << endl;
}
return EXIT_SUCCESS;
}
#include <iostream>
#include <unordered_map>
#include <algorithm>
int main()
{
std::unordered_map<char,int> m;
std::string s("abcba");
std::for_each(s.begin(), s.end(), [&m](char &c) { m[c]++; });
char ch = 's';
if (m.find(ch) != m.end()) {
std::cout << "Key found";
} else {
std::cout << "Key not found";
}
return 0;
}