把每一行的0或1用bool值表示
List = list(map(int, input().split()))
Count = 0
k = 1
Bool = False #因为矩阵内是0与1,所以我认为用bool类型方便点
while k < len(List):
for i in range(0, List[k]): #List[k]存放0或1的连续次数
print(int(Bool), end = '')
Count += 1
if Count % List[0] == 0:
print()
k += 1
Bool = not Bool #输出完该次bool值的List[k]次,则转换bool值
个人因看错题又尝试了矩阵转置输出······
```python
List = list(map(int, input().split()))
array = []#存放所有行,形成二维数组
Bool = False
k = 1
array1 = []#中间变量,存放每一行的bool值
Count = 0
while k < len(List):
for i in range(0, List[k]):
array1.append(int(Bool))#把每一个bool值放入行内
Count += 1
if Count % List[0] == 0:
array.append(array1)#若该行已满,则该行放入列表内
array1 = []
k += 1
Bool = not Bool
Count = 0
for i in range(0, List[0]):#矩阵的转置输出
for j in range(0, List[0]):
print(array[j][i], end = '')
Count += 1
if Count % List[0] == 0:
print()