题 从键盘中输入10个整数,并放入一个一维数组中,然后将其前5个元素与后
题从键盘中输入10个整数,并放入一个一维数组中,然后将其前5个元素与后5个元素对换,即第一个元素与第十个元素互换,第二个元素和第九个元素对换......第五个与第六个互换...
题
从键盘中输入10个整数,并放入一个一维数组中,然后将其前5个元素与后5个元素对换,即第一个元素与第十个元素互换,第二个元素和第九个元素对换......第五个与第六个互换.分别输出数组原来各元素的值和对换后个元素的值. 展开
从键盘中输入10个整数,并放入一个一维数组中,然后将其前5个元素与后5个元素对换,即第一个元素与第十个元素互换,第二个元素和第九个元素对换......第五个与第六个互换.分别输出数组原来各元素的值和对换后个元素的值. 展开
1个回答
展开全部
Private Sub Command1_Click()
Dim A(10) As Long,I As Long
For I = 1 To 10
A(I) = InputBox("请输入第" & I & "个数据","提示","")
Print A(I),
Next
Print
For I = 1 To 5 '5是因为元素个数\2
A(0) = A(I)
A(I) = A(11 - I) '11是元素个数+1
A(11 - I) = A(0)
Next
For I = 1 To 10
Print A(I),
Next
End Sub
Dim A(10) As Long,I As Long
For I = 1 To 10
A(I) = InputBox("请输入第" & I & "个数据","提示","")
Print A(I),
Next
For I = 1 To 5 '5是因为元素个数\2
A(0) = A(I)
A(I) = A(11 - I) '11是元素个数+1
A(11 - I) = A(0)
Next
For I = 1 To 10
Print A(I),
Next
End Sub
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询