본문 바로가기

Algorithm/SWEA

[SWEA] 2050. 알파벳을 숫자로 변환 D1 JAVA

반응형


문제 이해

 

아이디어

더보기

A는 65니까 1번부터 인덱싱 하려면 64빼주면 됌

 

코드

import java.util.Scanner;
import java.io.FileInputStream;

class Solution
{
	public static void main(String args[]) throws Exception
	{
   		Scanner sc = new Scanner(System.in);
		String str = sc.nextLine();
		StringBuilder sb = new StringBuilder();
		sc.close();

		for (int i = 0; i < str.length(); i++) {
			char tmp = str.charAt(i);
			sb.append(tmp-64).append(" ");
		}
		System.out.println(sb);
	}
}

 

 


 

 

집사는개발자가되고파

 

choppadontbiteme.tistory.com

 

반응형