ICode国际青少年编程竞赛- Python-4级训练场-嵌套for循环练习
1、
for i in range(3):
Spaceship.step(4)
for j in range(4):
Dev.step(2)
Dev.turnRight()
Spaceship.turnLeft()
Spaceship.step(4)
Spaceship.turnRight()
2、
for i in range(4):
Spaceship.step(6)
for j in range(3):
Spaceship.turnLeft()
Spaceship.step(2)
3、
for i in range(3):
for j in range(3):
Dev.step(3)
Dev.turnLeft()
Dev.step(-2)
Dev.turnLeft()
4、
for i in range(3):
for j in range(3):
Spaceship.step(2)
Dev.step(3)
Dev.step(-3)
Spaceship.turnRight()
Spaceship.step(4)
Spaceship.turnLeft()
5、
for i in range(3):
for j in range(3):
Spaceship.step()
Dev.step(2)
Dev.step(-4)
Dev.step(2)
Spaceship.step()
Spaceship.turnRight()
Spaceship.step(3)
Spaceship.turnLeft()
6、
for i in range(4):
for j in range(4):
Dev.step()
Dev.turnLeft()
Dev.step()
Dev.turnRight()
Dev.turnLeft()
7、
for i in range(4):
Spaceship.step(4)
for k in range(4):
Dev.step(3)
Dev.turnRight()
Dev.step(2)
for i in range(2):
Spaceship.turnRight()
Spaceship.step(4)
Spaceship.turnLeft()
Dev.turnRight()
8、
for i in range(4):
Dev.step(4)
Dev.turnRight()
for j in range(3):
Dev.step(2)
Dev.turnLeft()
Dev.step(-4)
Dev.turnLeft()
9、
for i in range(4):
Spaceship.step(4)
for j in range(2):
Dev.step(3-j)
Dev.turnLeft()
Dev.step(-2)
Dev.turnRight()
Spaceship.turnRight()
Spaceship.step(4)
Spaceship.turnLeft()
Spaceship.step(4)
Dev.step(-1)
Dev.turnRight()
Spaceship.turnRight()
10、
for i in range(3):
Dev.turnLeft()
Spaceship.step(2)
Dev.step()
for j in range(2):
Dev.step(3)
Dev.turnRight()
Spaceship.step(3)
Dev.step(7)
Dev.step(-3)
Dev.turnLeft()
11、
for i in range(4):
for j in range(2):
Spaceship.step(6-j*3)
Spaceship.turnRight()
for k in range(2):
for j in range(2):
Dev.step(2)
Dev.turnRight()
Dev.step(2)
Spaceship.turnRight()
for j in range(2):
Spaceship.step(3+j*3)
Spaceship.turnLeft()
Dev.turnRight()
12、
for i in range(3):
for j in range(2):
Dev.step(4+j*2)
Dev.turnLeft()
for j in range(3):
Dev.step(-4)
Dev.turnRight()
13、
for i in range(4):
for j in range(3):
Spaceship.step(3)
Spaceship.turnRight()
Spaceship.step(1)
Spaceship.turnLeft()
Spaceship.step()
Spaceship.turnRight()
14、
for i in range(4):
for j in range(3):
Dev.step(2)
Dev.turnRight()
Dev.step(3)
Dev.turnLeft()
Dev.step(4)
Dev.turnLeft()
15、
for i in range(4):
Dev.step(-1)
Dev.turnLeft()
for j in range(2):
Dev.step(3)
Dev.turnRight()
Dev.step(4)
16、
for i in range(3):
Spaceship.step(4)
Spaceship.turnRight()
if i == 1:
Dev.turnLeft()
Dev.step()
for j in range(4):
Dev.step(3)
Dev.turnRight()
Dev.step(-1)
Spaceship.step(4)
Spaceship.turnLeft()
17、
Dev.turnRight()
for i in range(4):
Dev.step(1)
Dev.turnLeft()
Dev.step(3)
Dev.turnRight()
Dev.step(3)
if i == 0 or i == 3:
for j in range(4):
Dev.turnLeft()
Dev.step(-3)
Spaceship.step(3)
Dev.step(-4)
Spaceship.step(2)
18、
for i in range(4):
for j in range(3):
Dev.step(4)
Dev.turnLeft()
for j in range(2):
Dev.step(3-j)
Dev.turnRight()
Dev.step(-1)
19、
for i in range(4):
for j in range(3):
Dev.step(2)
Dev.turnRight()
for j in range(2):
Dev.step(4-j*2)
Dev.turnRight()
Dev.step(4-j*2)
20、
for i in range(4):
Spaceship.step(2)
Dev.step(2)
for j in range(2):
Dev.turnLeft()
Dev.step(-1)
Dev.turnRight()
Dev.step(1)
Dev.turnLeft()
Spaceship.step(4)
Spaceship.turnLeft()
Spaceship.step(4)
Dev.step(-2)