11319번: Count Me In백준/문제2024. 4. 30. 15:06
Table of Contents
문제 출처 : https://www.acmicpc.net/problem/11319
언어 : Kotlin
문제 설명 :
Given a sentence in English, output the counts of consonants and vowels.
Vowels are letters in [’A’,’E’,’I’,’O’,’U’,’a’,’e’,’i’,’o’,’u’].
입력 :
The test file starts with an integer S(1 ≤ S ≤ 100), the number of sentences.
Then follow S lines, each containing a sentence - words of length 1 to 20 separated by spaces. Every sentence will contain at least one word and be comprised only of characters [a-z][A-Z] and spaces. No sentence will be longer than 1000 characters.
출력 :
For each sentence, output the number of consonants and vowels on a line, separated by space.
제한 사항 :
- 시간 제한 : 1초
- 메모리 제한 : 256MB
입출력 예 :
입력 | 출력 |
3 You can win this thing May be too optimistic Just try to have fun |
12 6 10 8 11 5 |
풀이 :
import java.io.BufferedReader
import java.io.BufferedWriter
import java.io.InputStreamReader
import java.io.OutputStreamWriter
fun main() = with(BufferedReader(InputStreamReader(System.`in`))) {
val bw = BufferedWriter(OutputStreamWriter(System.out))
val s = readLine().toInt()
repeat(s) {
val arr = IntArray(2)
readLine().replace(" ", "").forEach {
when (it.lowercaseChar()) {
'a', 'e', 'i', 'o', 'u' -> arr[1]++
else -> arr[0]++
}
}
bw.appendLine(arr.joinToString(" "))
bw.flush()
}
bw.close()
}
'백준 > 문제' 카테고리의 다른 글
1972번: 놀라운 문자열 (0) | 2024.05.01 |
---|---|
23080번: 스키테일 암호 (0) | 2024.04.30 |
2257번: 화학식량 (0) | 2024.04.30 |
30402번: 감마선을 맞은 컴퓨터 (0) | 2024.04.29 |
9494번: Text Roll (0) | 2024.04.29 |
@스몰스테핑 :: 작은 발걸음
포스팅이 좋았다면 "좋아요❤️" 또는 "구독👍🏻" 해주세요!