๋ฐ์ํ
๋ฌธ์ ๋งํฌ
https://www.acmicpc.net/problem/10820
๋ด๊ฐ ํผ ํ์ด
- ์ ๋ ฅ๋ฐ์ character๋ฅผ ๋ชจ๋ ํ ๋ฌธ์์ฉ ๋ฏ์ด์ ๋ฐฐ์ด๋ก ์ ์ฅํด์ค ๋ค์, if ๋ฌธ์ ํ์ฉํด์ count
while let input = readLine() {
var str = Array(input)
var lower = 0
var upper = 0
var num = 0
var space = 0
for i in str {
if i >= "a" && i <= "z" {
lower += 1
} else if i >= "A" && i <= "Z" {
upper += 1
} else if i == " " {
space += 1
} else {
num += 1
}
}
print("\(lower) \(upper) \(num) \(space)")
}
๋ฐ์ํ
'Algorithm > Baekjoon' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[๋ฐฑ์ค] (Swift) 10824๋ฒ - ๋ค ์ (0) | 2022.02.18 |
---|---|
[๋ฐฑ์ค] (Swift) 11655๋ฒ - ROT13 (0) | 2022.02.17 |
[๋ฐฑ์ค] (Swift) 2743๋ฒ - ๋จ์ด ๊ธธ์ด ์ ๊ธฐ (0) | 2022.02.16 |
[๋ฐฑ์ค] (Swift) 10809๋ฒ - ์ํ๋ฒณ ์ฐพ๊ธฐ (0) | 2022.02.15 |
[๋ฐฑ์ค] (Swift) 10808๋ฒ - ์ํ๋ฒณ ๊ฐ์ (0) | 2022.02.13 |