Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <map>
- std::string ZamijeniPremaRjecniku(std::string recenica, std::map<std::string, std::string> mapa)
- {
- std::string novi;
- for(int i=0; i<recenica.length(); i++)
- {
- std::string pomocni;
- while(recenica[i]!=' ' && i<recenica.length()) { pomocni.push_back(recenica[i]); i++; }
- novi = novi + mapa[pomocni] + " ";
- }
- return novi;
- }
- int main()
- {
- std::map<std::string, std::string> rjecnik {{"jabuka", "apple"},
- {"da", "yes"}, {"kako", "how"}, {"ne", "no"}, {"majmun", "monkey"}};
- std::cout << ZamijeniPremaRjecniku("kako da ne", rjecnik);
- return 0;
- }
Add Comment
Please, Sign In to add comment