Created
July 8, 2023 05:37
-
-
Save KaitoMuraoka/c1461f49a2558bf34e9ddaf746081ae1 to your computer and use it in GitHub Desktop.
Standard input given a board (n x m のマス目が与えられた時の標準入力)
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
private func readStringArray(_ count: Int) -> [[Character]] { | |
return (1...count).map { _ in | |
let value = Array(readLine()!) | |
return Array<Character>(value) | |
} | |
} | |
//example: | |
// | |
//count = 3 | |
//..... | |
//.#.#. | |
//..... | |
// outPut: | |
//[[".", ".", ".", ".", "."], [".", "#", ".", "#", "."], [".", ".", ".", ".", "."]] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
概要
競技プログラミングとかである、「H×W のマス目」が標準入力で与えられた場合の処理関数を作成しました。
マス目を入力すると二重配列で出力されます。
count
には列の数を入れてください。例
3 x 5のマス目
がある場合、
count
は3になります。これを入力すると以下のような二重配列の形で出力されます。
What is this?
I have created a function that handles the case where the "H x W squares" are given as standard input, which is competition programming or something like that.
When the squares are entered, they are output as a double array.
The
count
should be the number of columns.Example
3 x 5 squares
is present, the
count
is 3.If you type this in, the output will be in the form of a double array as follows.