No older revisions available
No older revisions available
~cpp
# -*- coding: cp949 -*-
mapx=0
mapy=0
#map = ['*...','....','.*..','....']
map = []
def plus(r,c):
if r<0 or r>mapx-1:
return 0
if c<0 or r>mapy-1:
return 0
if map[r][c] != '*':
map[r]=map[r][:c] + str(int(map[r][c])+1) + map[r][c+1:]
def mineAroundplus(r,c):
plus(r-1,c-1)
plus(r-1,c)
plus(r-1,c+1)
plus(r,c-1)
plus(r,c)
plus(r,c+1)
plus(r+1,c-1)
plus(r+1,c)
plus(r+1,c+1)
def prtmap():
prt = ''
for i in range(0,mapy):
for j in range(0,mapx):
prt = prt + map[i][j]
print prt
prt =''
###################################### main
mapx = input('x >')
mapy = input('y >')
#입력받은 행 열 만큼 데이터를 입력받습니다.
for i in range(mapy):
map.append(raw_input())
px = 0
py = 0
#.을 0으로 변경해줍니다.
for i in range(0,mapy):
for j in range(0,mapx):
if map[i][j] == '.':
map[i] = map[i][:j] + '0' + map[i][j+1:]
#마인 주변에 있는 숫자들을 더합니다
for i in range(0,mapy):
for j in range(0,mapx):
if map[i][j] == '*':
mineAroundplus(i,j)
prtmap()