티스토리 뷰
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.io.*; | |
import java.util.*; | |
class Main { | |
public static void main(String[] args) throws IOException { | |
BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); | |
String[] input = in.readLine().split("-"); | |
int length = input.length; | |
String result = ""; | |
for(int i=0; i<length; ++i) { | |
String name = input[i]; | |
result += String.valueOf(name.charAt(0)); | |
} | |
System.out.println(result); | |
} | |
} |
문자열 처리.
하지만 KMP 알고리즘
이라는 관련 알고리즘이 따로 있는 것 같다. 나중에 공부해보자...
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let input = readLine()!.split(separator: "-") | |
let count = input.count | |
var result = "" | |
for i in 0..<count { | |
let name = input[i].description | |
result += name[name.startIndex].description | |
} | |
print(result) |
'Algorithm > Baekjoon Online Judge' 카테고리의 다른 글
11725번 '트리의 부모 찾기' (0) | 2018.08.11 |
---|---|
1991번 '트리 순회' (0) | 2018.08.10 |
10451번 '순열 사이클' (0) | 2018.08.10 |
3036번 '링' (0) | 2018.08.10 |
1850번 '최대공약수' (0) | 2018.08.10 |