谁能解释一下这个程序的具体逻辑,有急用,GraphicsWindow.BackgroundColor = "Black"x = 100y = 100For i = 1 To 100000r = Math.GetRandomNumber(3)ux = 150uy = 30If (r = 1) thenux = 30uy = 1000EndIfIf (r = 2) Thenux = 1000uy = 1000EndIfx = (

来源:学生作业帮助网 编辑:作业帮 时间:2024/04/29 17:51:37
谁能解释一下这个程序的具体逻辑,有急用,GraphicsWindow.BackgroundColor =

谁能解释一下这个程序的具体逻辑,有急用,GraphicsWindow.BackgroundColor = "Black"x = 100y = 100For i = 1 To 100000r = Math.GetRandomNumber(3)ux = 150uy = 30If (r = 1) thenux = 30uy = 1000EndIfIf (r = 2) Thenux = 1000uy = 1000EndIfx = (
谁能解释一下这个程序的具体逻辑,有急用,
GraphicsWindow.BackgroundColor = "Black"
x = 100
y = 100
For i = 1 To 100000
r = Math.GetRandomNumber(3)
ux = 150
uy = 30
If (r = 1) then
ux = 30
uy = 1000
EndIf
If (r = 2) Then
ux = 1000
uy = 1000
EndIf
x = (x + ux) / 2
y = (y + uy) / 2
color = GraphicsWindow.GetRandomColor()
GraphicsWindow.SetPixel(x,y,color)
EndFor

谁能解释一下这个程序的具体逻辑,有急用,GraphicsWindow.BackgroundColor = "Black"x = 100y = 100For i = 1 To 100000r = Math.GetRandomNumber(3)ux = 150uy = 30If (r = 1) thenux = 30uy = 1000EndIfIf (r = 2) Thenux = 1000uy = 1000EndIfx = (
简单解释下:这个程序是设置窗体背景颜色的程序.x,y是一个初始值.后面,使用getrandomnumber函数来生成r变量,通过这个变量来确定像素的位置.最后,通过一个gerrandomcolor函数来产生一个随机的颜色,然后再同setpixel函数来把这个颜色设置到计算出的x,y位置.这个程序中有一点需要结合整体程序来理解,就是for循环的使用,意思是产生10000个不同的设置点,但是,其中的位置却没有相应的进行改变;