3个回答
展开全部
把最后一个放到一个临时变量,然后运用循环将倒数第二个赋给倒数第一个,倒数第三个赋给倒数第二个,。。。。。,最后把临时变量赋给第一个元素。如果要我给出源码来就没意思了。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
Private Sub Form_Load()
'创建一个数组
Dim a(9) As Integer
'初始化数组
Dim i As Integer
For i = 0 To UBound(a)
a(i) = i + 1
Next
'插入操作
Dim temp1 As Integer, temp2 As Integer '定义2个临时变量
temp1 = a(UBound(a)) '临时变量1初始值设置为最后一个值
For i = 0 To UBound(a)
temp2 = a(i)
a(i) = temp1
temp1 = temp2
Next
'测试结果
Dim str As String
str = ""
For i = 0 To UBound(a)
str = str & "第" & i + 1 & "项: " & a(i) & vbCrLf
Next
Debug.Print str
End Sub
'创建一个数组
Dim a(9) As Integer
'初始化数组
Dim i As Integer
For i = 0 To UBound(a)
a(i) = i + 1
Next
'插入操作
Dim temp1 As Integer, temp2 As Integer '定义2个临时变量
temp1 = a(UBound(a)) '临时变量1初始值设置为最后一个值
For i = 0 To UBound(a)
temp2 = a(i)
a(i) = temp1
temp1 = temp2
Next
'测试结果
Dim str As String
str = ""
For i = 0 To UBound(a)
str = str & "第" & i + 1 & "项: " & a(i) & vbCrLf
Next
Debug.Print str
End Sub
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
Private Sub Command1_Click()
Dim a(10) As Integer
Dim i As Integer
Dim temp As Integer
For i = 1 To 10
a(i) = i
Print i;
Next i
Print
temp = a(1)
For i = 1 To 9
a(i) = a(i + 1)
Print a(i);
Next i
a(10) = temp
Print a(10)
End Sub
如果需要换成自己的数据,则需要把a(i)=i修改,例如a(i)=InputBox("请输入数据:"),就可以了。
Dim a(10) As Integer
Dim i As Integer
Dim temp As Integer
For i = 1 To 10
a(i) = i
Print i;
Next i
temp = a(1)
For i = 1 To 9
a(i) = a(i + 1)
Print a(i);
Next i
a(10) = temp
Print a(10)
End Sub
如果需要换成自己的数据,则需要把a(i)=i修改,例如a(i)=InputBox("请输入数据:"),就可以了。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询