
switch(dir%4)//pos表示方向:0向上;1向右;2向下;3向左。初始化为0
{
case 0:
while (r-->0 && x >= 0)
帆判旦 {
str[x--][y]=tmp
}
x++
break
case 1:
while (r-->0 && y<COW)
{
str[x][y++]=tmp
}
y--
break
case 2:
while (r-->0 && x<COW)
{
str[x++][y]=tmp
}
x--
态扰 break
case 3:
while (r-->0 && y>=0)
{
str[x][y--]=tmp
冲腔 }
y++
break
}
一只小海龟(tutle库的使用)课程内容如下:
1.召唤小海龟,导入turtle及设置海龟图形
import turtle
turtle.shape("turtle")
2.设置背景颜色为蓝色
turtle.bgcolor("blue")
3.让小海龟向前出发,移动距离为150px
turtle.forward(150)
turtle.right(90)
5.经过几轮直败闭胡行与右转的组合,最态含终形成正方形,最后再将正方形上色
turtle.fillcolor("yellow")
turtle.begin_fill()
结束
turtle.end_fill()
6.完整代码如下:
import turtle
turtle.shape("turtle")
turtle.bgcolor("blue")
turtle.fillcolor("yellow")
turtle.begin_fill()
#移动距离为150px
turtle.forward(150)
#右转角度为90°
turtle.right(90)
#移察拦动距离为150px
turtle.forward(150)
#右转角度为90°
turtle.right(90)
#移动距离为150px
turtle.forward(150)
#右转角度为90°
turtle.right(90)
#移动距离为150px!
turtle.forward(150)
turtle.end_fill()
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)