fork(1) download
  1. #include <iostream>
  2. #include <unordered_map>
  3. #include <unordered_set>
  4. #include <vector>
  5.  
  6. using namespace std;
  7.  
  8. int main()
  9. {
  10. unordered_map<string,vector<string>> komendy = {
  11. {"slowo1", {"wyraz1", "wyraz2", "wyraz3"}},
  12. {"slowo2", {"wyraz4", "wyraz5", "wyraz6"}}
  13. };
  14.  
  15. unordered_set<string> lista;
  16.  
  17. string in;
  18. while(cin >> in){
  19. auto it = komendy.find(in);
  20. if(it == end(komendy)) continue;
  21. lista.insert(begin(it->second),end(it->second));
  22. }
  23.  
  24. // wypisanie listy
  25. for(string const& s : lista) cout << s << ", ";
  26. }
  27.  
  28.  
Success #stdin #stdout 0s 3484KB
stdin
slowo1
slowo2
slowo1
niepoprawneslowo
slowo1
stdout
wyraz6, wyraz5, wyraz4, wyraz3, wyraz2, wyraz1,