fork download
  1. #include <string>
  2. #include <iostream>
  3. #include <utility>
  4. #include <numeric>
  5. #include <limits>
  6. #include <array>
  7.  
  8. int main()
  9. {
  10. std::string s = "cat can run fast";
  11.  
  12. std::array<char, std::numeric_limits<char>::max()> xlat;
  13. std::iota(xlat.begin(), xlat.end(), 0);
  14. std::swap(xlat['a'], xlat['c']);
  15.  
  16. for(char& c: s)
  17. c = xlat[c];
  18.  
  19. std::cout << s << '\n';
  20. }
  21.  
Success #stdin #stdout 0s 3028KB
stdin
Standard input is empty
stdout
act acn run fcst