Advertisement
sellmmaahh

popravni-2014-zad4-Monoalfabetski Sistem

Jul 31st, 2015
224
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.54 KB | None | 0 0
  1. #include <iostream>
  2. #include <vector>
  3. #include <stdexcept>
  4. #include <map>
  5.  
  6.  
  7. using namespace std;
  8.  
  9. string Sifrirani (string s, map<char,char> m)
  10. {
  11.     string novi;
  12.     novi.resize(s.length());
  13.     for (int i=0; i<s.length(); i++) {
  14.         for (auto it=m.begin(); it!=m.end(); it++) {
  15.             if (s[i]==it->first)
  16.                 novi[i]=it->second;
  17.         }
  18.     }
  19.     return novi;
  20. }
  21.  
  22. int main () {
  23. string s {"abcbcaccbac"};
  24. map<char,char> mapa {{'a','x'},{'b','c'},{'c','a'}};
  25. string rez{Sifrirani(s,mapa)};
  26. cout<<rez;
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement