fork download
  1. import java.util.*;
  2. import java.lang.*;
  3. import java.io.*;
  4.  
  5. class Ideone
  6. {
  7. public static void main (String[] args) throws java.lang.Exception
  8. {
  9. Scanner in = new Scanner(System.in);
  10. String str = in.nextLine();
  11. char[] s = str.toCharArray();
  12. int ABC_SIZE = 26;
  13. int k = in.nextInt();
  14. String str1 = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
  15. char[] s1 = str1.toCharArray();
  16. for(int i = 0; i < s.length; i++){
  17. int find = s[i] - 'A';
  18. if(find - k < 0) s[i] = s1[ABC_SIZE - (k - find)];
  19. else s[i] = s1[find-k];
  20.  
  21. }
  22. System.out.println(s);
  23. }
  24. }
Success #stdin #stdout 0.06s 2184192KB
stdin
WURYAD
4
stdout
SQNUWZ