用VB2005程序编程:从键盘上输入10个整数,并放入一个一维数组中,然后将其前5个元素与后5个元素对换
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
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
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询