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