Bibi's DevLog ๐Ÿค“๐ŸŽ

[๋ฐฑ์ค€ 3035] ์Šค์บ๋„ˆ (Swift) ๋ณธ๋ฌธ

ํ”„๋กœ๊ทธ๋ž˜๋ฐ/์•Œ๊ณ ๋ฆฌ์ฆ˜ ํ’€์ด Swift

[๋ฐฑ์ค€ 3035] ์Šค์บ๋„ˆ (Swift)

๋น„๋น„ bibi 2022. 10. 5. 12:03

3035๋ฒˆ: ์Šค์บ๋„ˆ

๋ฌธ์ œ๋ฅผ ์ดํ•ดํ•˜๋Š” ๋ฐ ์ข€ ์˜ค๋ž˜ ๊ฑธ๋ ธ๋˜ ๋ฌธ์ œ..๐Ÿค”

์ฒซ ์ค„์ดํ›„ ์ฃผ์–ด์ง€๋Š” ์ž…๋ ฅ์˜ ๊ฐ๊ฐ์˜ ๋ฌธ์ž๋ฅผ ZR*ZC๋งŒํผ ์ถœ๋ ฅํ•˜๋Š” ๋ฌธ์ œ์ด๋‹ค.

  • m*n ํ–‰๋ ฌ : ๊ฐ€๋กœ๋กœ m์ค„, ์„ธ๋กœ๋กœ n์ค„
    • ํ–‰ = row = ๊ฐ€๋กœ
    • ์—ด = column = ์„ธ๋กœ

์ค‘์ฒฉ ๋ฐ˜๋ณต๋ฌธ๋งŒ ํ—ท๊ฐˆ๋ฆฌ์ง€ ์•Š๊ณ  ์ž˜ ์‚ฌ์šฉํ•˜๋ฉด ํ’€ ์ˆ˜ ์žˆ๋‹ค.

  • ๊ฐ ๋ฌธ์ž๋ณ„๋กœ ZC๋งŒํผ ๋ฐ˜๋ณตํ•ด ํ•œ ์ค„์„ ๋งŒ๋“  ๋’ค,
  • ๋งŒ๋“  ํ•œ ์ค„์„ ZR๋งŒํผ ๋ฐ˜๋ณต ์ถœ๋ ฅํ•œ๋‹ค.

ํ’€์ด

let inputArr = readLine()!.split(separator: " ").map { Int($0)! }
let r = inputArr[0]
let c = inputArr[1]
let zr = inputArr[2] // ์„ธ๋กœ
let zc = inputArr[3] // ๊ฐ€๋กœ
var answer: [String] = []
for _ in (1...r) {
    var input = readLine()!
    var line = ""
    for _ in (1...zr) {
        for char in input {
            for _ in (1...zc) {
                line.append(char)
            }
        }
        answer.append(line)
        line = ""
    }
}
answer.forEach { print($0) }