用vb程序代码实现将一个一维数组中元素向右循环移动,移动次数由文本框Tex
用Vb编写程序代码实现将一个一维数组中元素向右循环移动,移动次数由文本框Textl输入。例如数组各元素的值依次为0,1,2,3,4,5,6,7,8,9,10;移动三次后,...
用Vb编写程序代码实现将一个一维数组中元素向右循环移动,移动次数由文本框Textl输入。例如数组各元素的值依次为0,1,2,3,4,5,6,7,8,9,10;移动三次后,各元素的值依次为8,9,10,0,1,2,3,4,5,6,7。
展开
1个回答
展开全部
建一个Command1,单击按钮即可。如果你想检验结果,请把3句开头是'的语句的'去掉。
代码如下。
=================
Dim a(10)
Private Sub Command1_Click()
Dim i As Integer, j As Integer, t As Single
For i = 1 To Text1.Text
t = a(10)
For j = 10 To 1 Step -1
a(j) = a(j - 1)
Next
a(0) = t
Next
'For i = 0 To 10
'Print a(i)
'Next
End Sub
Private Sub Form_Load()
Dim i As Integer
For i = 0 To 10
a(i) = i
Next
End Sub
代码如下。
=================
Dim a(10)
Private Sub Command1_Click()
Dim i As Integer, j As Integer, t As Single
For i = 1 To Text1.Text
t = a(10)
For j = 10 To 1 Step -1
a(j) = a(j - 1)
Next
a(0) = t
Next
'For i = 0 To 10
'Print a(i)
'Next
End Sub
Private Sub Form_Load()
Dim i As Integer
For i = 0 To 10
a(i) = i
Next
End Sub
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询