2
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

標準入力で入力された高さと長さが分かる図形を二次元配列にする

Last updated at Posted at 2021-03-05

#今回、例に出す図形
今回、例として出す入力は、

例1(文字列の場合)
4 7
O O O X O O O
O O X X X O O
O X X X X X O
X X X X X X X

例2(数字列の場合)
4 7
0 0 0 1 0 0 0
0 0 1 1 1 0 0
0 1 1 1 1 1 0
1 1 1 1 1 1 1

#文字列の場合

h ,w = [int(x) for x in input().split()]
l = [input().split() for _ in range(h)]
print(l)

#数列の場合

h ,w = [int(x) for x in input().split()]
l = [[int(x) for x in input().split()] for _ in range(h)]
print(l)

#全ての結果

#結果(文字列の結果)
[['O', 'O', 'O', 'X', 'O', 'O', 'O'],
 ['O', 'O', 'X', 'X', 'X', 'O', 'O'],
 ['O', 'X', 'X', 'X', 'X', 'X', 'O'],
 ['X', 'X', 'X', 'X', 'X', 'X', 'X']]
#結果(数列の場合)
[[0, 0, 0, 1, 0, 0, 0],
 [0, 0, 1, 1, 1, 0, 0],
 [0, 1, 1, 1, 1, 1, 0],
 [1, 1, 1, 1, 1, 1, 1]]

#終わりに
初めてQiitaで記事を試しに書いてみました。まだPython3の経験が3ヶ月なので、これから暇つぶしに書いていこうと思います。

2
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?