Vb编一程序,将一维数组中元素向右循环移位,移位次数键盘输入。
展开全部
Dim str As String = ""
Dim n, m As Integer
Dim a() As Integer
n = InputBox("请输入要产生随机数的个数n")
m = InputBox("请输入要移动的位数m")
ReDim a(n)
str = "生成数组为" & vbCrLf
For i = 1 To n
a(i) = Int(Rnd() * 90 + 10)
str = str & a(i) & " "
Next
Dim b(m), c(n) As Integer
For i = 1 To m
b(i) = a(n - m + i)
Next
For i = 1 To m
c(i) = b(i)
Next
For i = m + 1 To n
c(i) = a(i - m)
Next
str = str & vbCrLf & "移动后的数组为" & vbCrLf
For i = 1 To n
str = str & c(i) & " "
Next
TextBox6.Text = str
追问
这个程序没结束吧????
追答
移动后的数组都输出了,已经结束了
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询