You are viewing a single comment's thread. Return to all comments →
C++11 using std::multimap and storing the complete database. Sorry for the mangled format.
std::multimap
#include <regex> #include <string> #include <iostream> #include <map> int main() { std::multimap<std::string, std::string> database; int n; std::string dbKey, dbValue; if (std::cin >> n) for (int i = 0; i < n; i++) { std::cin >> dbKey >> dbValue; database.insert({dbKey, dbValue}); } std::string pattern("gmail.com"); std::regex r(pattern); std::string domain; for (auto it = database.cbegin(); it != database.cend(); it++) { domain = it->second.substr(it->second.find('@')+1); if (std::regex_match(domain, r)) std::cout << it->first << std::endl; } return 0; }
Seems like cookies are disabled on this browser, please enable them to open this website
Day 28: RegEx, Patterns, and Intro to Databases
You are viewing a single comment's thread. Return to all comments →
C++11 using
std::multimap
and storing the complete database. Sorry for the mangled format.