fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. string simpleCipher(string encrypted, int k) {
  5. k %= 26;
  6.  
  7. for (char &c : encrypted) {
  8. c = ((c - 'A' - k + 26) % 26) + 'A';
  9. }
  10.  
  11. return encrypted;
  12. }
  13.  
  14. int main() {
  15. string encrypted;
  16. int k;
  17.  
  18. cin >> encrypted >> k;
  19.  
  20. cout << simpleCipher(encrypted, k);
  21.  
  22. return 0;
  23. }
Success #stdin #stdout 0.01s 5316KB
stdin
VTAOG
2
stdout
TRYME