谁能解释一下这个程序的具体逻辑,有急用,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/07/11 00:59:39
![谁能解释一下这个程序的具体逻辑,有急用,GraphicsWindow.BackgroundColor =](/uploads/image/z/3344957-53-7.jpg?t=%E8%B0%81%E8%83%BD%E8%A7%A3%E9%87%8A%E4%B8%80%E4%B8%8B%E8%BF%99%E4%B8%AA%E7%A8%8B%E5%BA%8F%E7%9A%84%E5%85%B7%E4%BD%93%E9%80%BB%E8%BE%91%2C%E6%9C%89%E6%80%A5%E7%94%A8%2CGraphicsWindow.BackgroundColor+%3D+%22Black%22x+%3D+100y+%3D+100For+i+%3D+1+To+100000r+%3D+Math.GetRandomNumber%283%29ux+%3D+150uy+%3D+30If+%28r+%3D+1%29+thenux+%3D+30uy+%3D+1000EndIfIf+%28r+%3D+2%29+Thenux+%3D+1000uy+%3D+1000EndIfx+%3D+%28)
谁能解释一下这个程序的具体逻辑,有急用,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个不同的设置点,但是,其中的位置却没有相应的进行改变;