https://www.acmicpc.net/problem/27866
27866번: 문자와 문자열
첫째 줄에 영어 소문자와 대문자로만 이루어진 단어 $S$가 주어진다. 단어의 길이는 최대 $1\,000$이다. 둘째 줄에 정수 $i$가 주어진다. ($1 \le i \le \left|S\right|$)
www.acmicpc.net
import java.util.Scanner;
public class Main{
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
String[] array = sc.next().split("");
int index = sc.nextInt();
System.out.println(array[index-1]);
sc.close();
}
}
'프로그래밍언어 > 알고리즘' 카테고리의 다른 글
백준 9086 문자열_JAVA (0) | 2023.05.09 |
---|---|
백준 2734 단어 길이 재기_JAVA (0) | 2023.05.09 |
백준 1546 평균_JAVA (0) | 2023.05.09 |
백준 10811 바구니 뒤집기_JAVA (0) | 2023.05.07 |
백준 3052 나머지_JAVA (0) | 2023.05.07 |