# 11447 - Use std::map >author: Utin ###### tags: `STL` --- ## Brief See the code below ## Solution 0 ```cpp= #include <bits/stdc++.h> #include "function.h" void oj::insert(std::map<int, oj::String> &ma, int key, const std::string &str) { std::string insertion = str; for (auto it : ma) { if (it.first == key) { insertion += it.second.str; ma.erase(key); break; } } ma.insert({key, oj::String(insertion)}); } void oj::output(const std::map<int, oj::String> &ma, int begin, int end) { for (auto it = ma.begin(); it != ma.end(); it++) if (it->first >= begin && it->first <= end) std::cout << it->second << ' '; } void oj::erase(std::map<int, oj::String> &ma, int begin, int end) { for (int i = begin; i <= end; i++) ma.erase(i); } std::ostream &oj::operator<<(std::ostream &output, const std::map<int, oj::String> &x) { for (auto it : x) output << it.second << ' '; return output; } // By Utin ``` ## Reference
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up