fork download
  1. #include <algorithm>
  2. #include <iostream>
  3. #include <unordered_map>
  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. vector<string> lista;
  16.  
  17. string in;
  18. while(cin >> in){
  19. auto it = komendy.find(in);
  20. if(it == end(komendy)) continue;
  21.  
  22. for(string const& s : it->second){
  23. auto znaleziono = find(begin(lista),end(lista),s);
  24. if(znaleziono == end(lista)) lista.push_back(s);
  25. }
  26. }
  27.  
  28. // wypisanie listy
  29. for(string const& s : lista) cout << s << ", ";
  30. }
  31.  
  32.  
Success #stdin #stdout 0s 3440KB
stdin
slowo1
slowo2
slowo1
niepoprawneslowo
slowo1
stdout
wyraz1, wyraz2, wyraz3, wyraz4, wyraz5, wyraz6,