2021-09-03 00:14
西安交通大学 大数据开发工程师 0 点赞 评论 收藏
分享
agnostic123:n_input=int(input())
m_input=int(input())
str_mn=input()
total_list=[]
sum=0
matrixA=[]#状态矩阵
for i in range(n_input):
matrixA.append([False]*m_input)
mn_list=str_mn.split(' ')
for i in range(n_input):
total_list.append(mn_list[i*m_input:(i+1)*m_input])
# print(total_list)
for n_i in range(len(total_list)-1):
for m_j in range(len(total_list[n_i])-1):
if matrixA[n_i][m_j]!=True:
print(total_list[n_i][m_j])
if int(total_list[n_i][m_j])==1 and int(total_list[n_i][m_j+1])==1 and int(total_list[n_i+1][m_j])==1 and int(total_list[n_i+1][m_j+1])==1:
sum+=1
matrixA[n_i][m_j]=True
matrixA[n_i][m_j+1]=True
matrixA[n_i+1][m_j]=True
matrixA[n_i+1][m_j+1]=True
else:
continue
print(sum)
投递阿里巴巴等公司10个岗位 >
0 点赞 评论 收藏
分享
关注他的用户也关注了: