본문 바로가기
알고리즘 & 자료구조/백준

백준 11655

by 신재권 2022. 2. 2.
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main11655 {

	public static void main(String[] args) throws IOException {
		
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String S = br.readLine();
		for(int i=0; i<S.length(); i++) {
			System.out.print(rot13(S.charAt(i)));
		}
		
	}
	
	public static char rot13(char c) {
		// A = 65, Z = 90 
		//만약 Z를 넘어가면 c - 'Z' + 'A' - 1
		if(c >= 65 && c<=90) {
			c +=13; 
			if(c > 90) {
				c -= 26;
			}	
		}else if(c>= 97 && c<=122) {
			c +=13; 
			if(c > 122) {
				c -= 26;
			}	
		}

		return c;
	}
	
	
}

 

'알고리즘 & 자료구조 > 백준' 카테고리의 다른 글

백준 2559_1  (0) 2022.02.04
백준 9996  (0) 2022.02.03
백준 10988_1  (0) 2022.02.01
백준 1159  (0) 2022.01.31
백준 10988  (0) 2022.01.30