fork download
  1. #include <string>
  2. #include <iostream>
  3.  
  4. using namespace std;
  5.  
  6. void gamma(string s1, string s2, string &res)
  7. {
  8. for (int i = 0; i < s1.length(); i++) {
  9. res[i] = (s1.c_str()[i]) ^ (s2.c_str()[i]);
  10. }
  11. }
  12.  
  13. int main(){
  14. string a = "abc";
  15. string b = "def";
  16. string c;
  17. string d;
  18. d.resize(a.length());
  19. cout << "BEFORE" << endl;
  20. cout << "c length = " << c.length() << "; ";
  21. cout << "d length = " << d.length() << endl;
  22. cout << "c (0,1,2) = " << (int)c[0] << ", " << (int)c[1] << ", " << (int)c[2] << endl;
  23. cout << "d (0,1,2) = " << (int)d[0] << ", " << (int)d[1] << ", " << (int)d[2] << endl;
  24.  
  25. gamma(a,b,c);
  26. gamma(a,b,d);
  27. cout << "AFTER" << endl;
  28. cout << "c length = " << c.length() << endl;
  29. cout << "d length = " << d.length() << endl;
  30. cout << "c (0,1,2) = " << (int)c[0] << ", " << (int)c[1] << ", " << (int)c[2] << endl;
  31. cout << "d (0,1,2) = " << (int)d[0] << ", " << (int)d[1] << ", " << (int)d[2] << endl;
  32.  
  33. return 0;
  34. }
  35.  
Success #stdin #stdout 0s 3472KB
stdin
Standard input is empty
stdout
19 1B 1E 
19 1B 1E