用VB2005程序编程:从键盘上输入10个整数,并放入一个一维数组中,然后将其前5个元素与后5个元素对换

即第1个元素与第10个元素对换,第2个与第九个元素对换、、、、
2024-12-30 01:52:46
推荐回答(1个)
回答1:

Private Sub Command1_Click()
Dim a(9) as integer, t as integer,i as byte
For i= 1 to 10
a(i-1)=int(inputbox("第"+cstr(i)+"个元素")
Next i
For i=1 to 10
Print "原始第"&cstr(i)&"个元素:"&cstr(a(i-1))
Next i
For i=1 to 5
t=a(i-1)
a(i-1)=a(10-i)
a(10-i)=t
Next i
For i=1 to 10
Print "当前第"&cstr(i)&"个元素:"&cstr(a(i-1))
Next i
End Sub