728x90
๋ฐ์ํ
๋ฌธ์ ์ค๋ช
์ด ๋ฌธ์ ์๋ ํ์ค ์
๋ ฅ์ผ๋ก ๋ ๊ฐ์ ์ ์ n๊ณผ m์ด ์ฃผ์ด์ง๋๋ค.
๋ณ(*) ๋ฌธ์๋ฅผ ์ด์ฉํด ๊ฐ๋ก์ ๊ธธ์ด๊ฐ n, ์ธ๋ก์ ๊ธธ์ด๊ฐ m์ธ ์ง์ฌ๊ฐํ ํํ๋ฅผ ์ถ๋ ฅํด๋ณด์ธ์.
์ ํ ์กฐ๊ฑด
- n๊ณผ m์ ๊ฐ๊ฐ 1000 ์ดํ์ธ ์์ฐ์์ ๋๋ค.
์์
์ ๋ ฅ
5 3
์ถ๋ ฅ
*****
*****
*****
ํ์ด:a๋งํผ์ *์ ๋ง๋ค๊ณ b๋งํผ ๋ฐ๋ณตํด์ ๋ํด์ค ๋ค ์ถ๋ ฅํจ 1์ผ ๊ฒฝ์ฐ์ for๋ฌธ์์ 1...0์ด ๋๋ฏ๋ก 1์ผ ๊ฒฝ์ฐ๋ง ๊ทธ๋ฅ ์ถ๋ ฅ
1
2
3
4
5
6
7
8
9
10
11
12
13
14
|
import Foundation
let n = readLine()!.components(separatedBy: [" "]).map { Int($0)! }
let (a, b) = (n[0], n[1])
var s = String(repeating: "*", count:a)
var answer = String(repeating: "*", count: a)
if b == 1 {
print(answer)
}else{
for _ in 1...b-1{
s += "\n\(answer)"
}
print(s)
}
http://colorscripter.com/info#e" target="_blank" style="color:#e5e5e5text-decoration:none">Colored by Color Scripter
|
๋ค๋ฅธ ์ฌ๋ ํ์ด ์ค ๊ฐ์ฅ ์ข๋ค๊ณ ์๊ฐํ๋ ๊ฒ
๊ฑ for๋ฌธ์ผ๋ก b๋งํผ ์ถ๋ ฅํ๋ฉด ๋๋ค..
1
2
3
4
5
6
7
8
|
import Foundation
let n = readLine()!.components(separatedBy: [" "]).map { Int($0)! }
let (a, b) = (n[0], n[1])
for _ in 0..<b {
print(String(repeating: "*", count: a))
}
http://colorscripter.com/info#e" target="_blank" style="color:#e5e5e5text-decoration:none">Colored by Color Scripter
|
728x90
๋ฐ์ํ
'๐ Problem Solution > Programmers' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
2018 KAKAO BLIND RECUITMENT 1์ฐจ ๋น๋ฐ์ง๋ Swift (0) | 2020.03.04 |
---|---|
ํ๋ก๊ทธ๋๋จธ์ค ์์ฐ Swift (0) | 2020.03.01 |
ํ๋ก๊ทธ๋๋จธ์ค x๋งํผ ๊ฐ๊ฒฉ์ด ์๋ n๊ฐ์ ์ซ์ Swift (0) | 2020.03.01 |
ํ๋ก๊ทธ๋๋จธ์ค ํ๋ ฌ์ ๋ง์ Swift (0) | 2020.03.01 |
ํ๋ก๊ทธ๋๋จธ์ค ํธ๋ํฐ ๋ฒํธ ๊ฐ๋ฆฌ๊ธฐ Swift (0) | 2020.03.01 |
๋๊ธ