编一vb程序,将一堆数组中的元素向左循环移位,移位次数由键盘输入
如数组各元素的原值依次为0,1,2,3,4,5,6,7,8,9,10;移位3次后,各元素值位3,4,5,6,7,8,9,10,0,1,2。...
如 数组各元素的原值依次为0,1,2,3,4,5,6,7,8,9,10;移位3次后,各元素值位3,4,5,6,7,8,9,10,0,1,2。
展开
1个回答
展开全部
Private Sub Command1_Click()
Dim a(11)
For i = 1 To 11
a(i) = InputBox("请输入第" & i & "个数字")
Print a(i) & " ";
Next
Print
n = InputBox("输入移动次数")
For j = 1 To n
k = a(1)
For i = 1 To 10
a(i) = a(i + 1)
Next i
a(11) = k
Next j
For i = 1 To 11
Print a(i) & " ";
Next
End Sub
Dim a(11)
For i = 1 To 11
a(i) = InputBox("请输入第" & i & "个数字")
Print a(i) & " ";
Next
n = InputBox("输入移动次数")
For j = 1 To n
k = a(1)
For i = 1 To 10
a(i) = a(i + 1)
Next i
a(11) = k
Next j
For i = 1 To 11
Print a(i) & " ";
Next
End Sub
本回答被提问者和网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询