0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

paizaラーニング問題集「【マップの扱い 1】マップの書き換え・1 マス」を解いてみた

Posted at

▼感想

横方向(x,W,i)を示す記号と、縦方向(y,H,j)を示す記号が混ざってしまわないように意識する必要があると感じました。コメントとしてコードに書いておくのがよいと思います。

▼コード


# 横方向 x,W,i
# 縦方向 y,H,j

########## 処理0(準備) インプット,リスト定義など ###########

H,W = map(int,input().split())

S = [[0 for i in range(W)] for j in range(H)]

for j in range(H):
    S[j] = list(input())
    
y,x = map(int,input().split())

########## 処理1 マップの書き換え、マップの出力 ##########

if S[y][x] == ".":
    S[y][x] = "#"
else:
    S[y][x] = "."

for j in range(H):
    print(*S[j],sep='')
0
0
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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?