fork(9) download
  1. #include <iostream>
  2. #include <string>
  3.  
  4.  
  5. std::string Encrypt(std::string, int);
  6.  
  7. int main(int argc, char *argv[])
  8. {
  9. std::string original = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
  10. std::string expected = "XYZABCDEFGHIJKLMNOPQRSTUVW" ;
  11.  
  12. std::string output = Encrypt(original,23) ;
  13.  
  14. if ( output != expected )
  15. {
  16. std::cout << "Output \"" << output << "\" differed from expected \""
  17. << expected << "\"\n" ;
  18. }
  19. else
  20. std::cout << "Ouput matched expected.\n" ;
  21. }
  22.  
  23. std::string Encrypt(std::string Source, int Key)
  24. {
  25. std::string Crypted = Source;
  26.  
  27. for(int Current = 0; Current < Source.length(); Current++)
  28. Crypted[Current] += Key;
  29.  
  30. return Crypted;
  31. }
  32.  
  33.  
Success #stdin #stdout 0s 3472KB
stdin
Standard input is empty
stdout
Output "XYZ[\]^_`abcdefghijklmnopq" differed from expected "XYZABCDEFGHIJKLMNOPQRSTUVW"