L = [[" " for i in range(10)] for j in range(10)]
for i in range (10):
L[9][i]="*"
for i in range (10):
L[8][i]="1"
for i in range (10):
L[7][i]="*"
for i in range (10):
L[6][i]="3"
for i in range (10):
L[5][i]="*"
print(L)
print()
def Check_Lines(l):
for i in range (10):
x=l[i].count("*")
if x == 10:
print ("LINE IS FULL")
del l[i]
l.reverse()
l.append([" "," "," "," "," "," "," "," "," "," "])
l.reverse()
Check_Lines(L)
print (L)
由于对python语言比较熟悉,所以我用python写了上面的函数。它所做的是搜索一个 10 x 10 的列表,如果单行用 * 填充,那么它将删除它并在顶部放置一个新的空行。
我知道 c 没有我使用的列表函数。有什么简单的方法可以解决我正在做的事情吗?