1、门禁系统
n = int(input())
numbering = list(map(int, input().split()))
print("1", end=" ")
for i in range(1, n):
count = 1
for j in range(i):
if numbering[j] == numbering[i]:
count += 1
print(count, end=" ")
2、Z字型扫描
n = int(input())
ans = []
matrix = []
for i in range(n):
row = list(map(int, input().split()))
matrix.append(row)
# print(matrix)
i, j = 0, 0
direction = "up"
while i < n and j < n:
ans.append(matrix[i][j])
if direction == "up":
if i == 0:
j += 1
direction = "down"
elif j == n - 1:
i += 1
direction = "down"
else:
i -= 1
j += 1
else:
if i == n - 1:
j += 1
direction = "up"
elif j == 0:
i += 1
direction = "up"
else:
i += 1
j -= 1
print(*ans)
ps:我也不知道为什么第二题只能得60分,求大佬指点~