seq1_values = [5, 40, 180, 13, 30, 20, 25, 24, 29, 31, 54, 46, 42, 50, 67, 17,
76, 33, 84, 35, 100, 37, 110, 32, 112, 15, 123, 3, 130, 42]
def get_num_values():
global seq1_values
return len( seq1_values )
def get_values():
global seq1_values
for value in seq1_values:
yield value
yield None
def next_value():
return next( next_value.values )
next_value.values = get_values()
def main():
numbers = []
value = next_value()
while value is not None:
numbers.append(value)
input_size = len(numbers)-1
for i in range(input_size):
print("|", str(input_size).rjust(4), end="")
for j in range(input_size):
print("|", str(value).rjust(4), end="")
value = next_value()
main()
输出应该如下所示:
| 0| 1| 2| 4| 5| 6| 7| 8| 9| 10| 11| 12| 13| 14| 15| 16| 17| 18| 19| 20| 21| 22| 23| 24| 25| 26| 27| 28| 29| 30|
| 5| 40| 180| 13| 30| 20| 25| 24| 29| 31| 54| 46| 42| 50| 67| 17| 76| 33| 84| 35| 100| 37| 110| 32| 112| 15| 123| 3| 130| 42|