马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
废话不多直接上代码(基于python3)half = 70
flag0 = ' '
flag1 = '0'
a = [[flag0]*half+[flag1]+[flag0]*half]
b_0 = [flag0,flag0,flag0]
b_1 = [flag0,flag0,flag1]
b_2 = [flag0,flag1,flag0]
b_3 = [flag0,flag1,flag1]
b_4 = [flag1,flag0,flag0]
b_5 = [flag1,flag0,flag1]
b_6 = [flag1,flag1,flag0]
b_7 = [flag1,flag1,flag1]
for i in range(1,half):
a.append([])
for j in range(2*half+1):
if j == 0 or j == 2*half:
a[i].append(flag0)
else:
c = a[i-1][j-1:j+2]
if c == b_0 or c == b_2 or c == b_5 or c == b_6 or c == b_3:
a[i].append(flag0)
elif c == b_1 or c == b_4 or c == b_7:
a[i].append(flag1)
for i in range(half):
print()
for j in range(2*half+1):
print(a[i][j],end="")
half可以自己改变长度
flag0和flag1的字符也可以自己改变二者长度相等就不影响结果
修改参数
half = 50
flag0 = '1'
flag1 = ' '
|