티스토리 뷰

반응형


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
 
// 2050. 알파벳을 숫자로 변환
public class Solution2050 {
    public void run() throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringBuilder sb = new StringBuilder();
                        // StringBuilder() : 문자열을 더할 때 새로운 객체를 생성하지 않고 기존의 데이터 더하는 방식
        
        char[] input =  br.readLine().trim().toCharArray();
                        // trim() : 문자열의 앞,뒤 공백 제거
                        // toCharArray() : 문자을 새로운 문자 배열로 변환
        for(int i=0; i<input.length; i++) {
            sb.append(((int) input[i] - 64+ " ");
        }
        
        System.out.println(sb.toString());
    }
    
    public static void main(String[] args) throws IOException {
        new Solution2050().run();
    }
}
cs


---

ABCDEFGHIJKLMNOPQRSTUVWXYZ

--

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 






반응형
댓글
최근에 올라온 글
최근에 달린 댓글
링크
Total
Today
Yesterday