fork download
  1. #include <iostream>
  2. #include <iterator>
  3. #include <algorithm>
  4.  
  5. template<typename InputIterator, typename OutputIterator, typename Key>
  6. void perform_xor(InputIterator begin, InputIterator end, OutputIterator out, Key const &key) {
  7. std::transform(begin, end, out, [key](auto &&value) {
  8. return value ^ key;
  9. });
  10. }
  11.  
  12. using namespace std;
  13.  
  14. int main() {
  15. char test[] = "(2*&.8\"\'*";
  16.  
  17. perform_xor(begin(test), end(test), begin(test), '&');
  18. copy(begin(test), end(test), ostream_iterator<int>(cout, " "));
  19.  
  20. cout << endl;
  21.  
  22. perform_xor(begin(test), end(test), begin(test), '&');
  23. copy(begin(test), end(test), ostream_iterator<char>(cout));
  24.  
  25. return 0;
  26. }
Success #stdin #stdout 0s 3456KB
stdin
Standard input is empty
stdout
14 20 12 0 8 30 4 1 12 38 
(2*&.8"'*