10953
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner in = new Scanner (System.in);
// testcase == 시도횟
int testcase = in.nextInt();
// testcase 만큼의 배열 선
String str [] = new String [testcase];
// 배열에 문자열 입
for (int i = 0 ; i < str.length; i++ ) {
str[i] = in.next();
}
// 해당 문자열의 0번 3번 문자를 정수로 변환하여 덧셈 출
for (int i = 0 ; i < str.length; i++ ) {
System.out.println(Integer.parseInt(String.valueOf(str[i].charAt(0)))
+ Integer.parseInt(String.valueOf(str[i].charAt(2))));
}
}
}
,
로 구분하여 앞의 수와 뒤의 수를 더한 결과를 출력하는 문제이다.
문제에서 수의 범위가 1자리라서 charAt()
을 사용하여 풀었는데 수의 자릿수가 가변적인 경우 substring
등을 이용하여 풀이도 가능하다.