假设数组a中有10个整型数据,循环左移5次,即第一个元素移至尾部,显示每次移动后的结果。
时间: 2023-05-16 13:05:22 浏览: 52
Sure, here's the code to achieve this:
```python
a = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
for i in range(5):
first = a[0]
a = a[1:]
a.append(first)
print(a)
```
This will output the following:
```
[2, 3, 4, 5, 6, 7, 8, 9, 10, 1]
[3, 4, 5, 6, 7, 8, 9, 10, 1, 2]
[4, 5, 6, 7, 8, 9, 10, 1, 2, 3]
[5, 6, 7, 8, 9, 10, 1, 2, 3, 4]
[6, 7, 8, 9, 10, 1, 2, 3, 4, 5]
```
Hope that helps!