Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.io.*;
- import java.math.* ;
- class Main
- {
- public static void main(String[] args) throws IOException {
- BufferedReader bi = new BufferedReader(new InputStreamReader(System.in));
- String line =bi.readLine();
- int i = Integer.parseInt(line);
- int key;
- int l;char c;
- int f;
- while(i!=0){
- i--;
- key = Integer.parseInt(bi.readLine());
- line = bi.readLine();
- for(l=0;l<line.length();l++){
- char d = line.charAt(l);
- if(d=='.'){
- System.out.print(" ");
- continue;
- }
- if(key<26){
- if(d>96){
- f = key ;
- if(d+f>122){
- d = (char)(96 + f - (122-d));
- }
- else {
- d = (char)(d + f);
- }
- }
- else{
- f = key ;
- if(d+f>90){
- d = (char)(64 + f - (90-d));
- }
- else {
- d = (char)(d + f);
- }
- }
- }
- else{
- if(d>96){
- f = key - 26;
- if(d+f>122){
- d = (char)(96 + f - (122-d));
- }
- else {
- d = (char)(d + f);
- }
- d =Character.toUpperCase(d);
- }
- else{
- f = key -26;
- if(d+f>90){
- d = (char)(64 + f - (90-d));
- }
- else {
- d = (char)(d + f);
- }
- d = Character.toLowerCase(d);
- }
- }
- System.out.print(d);
- }
- System.out.println();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement