下面的方法比较直观,在form1上放一个command1按钮,两个文本框按钮text1和text2:
Private Sub Command1_Click()
Dim a(10) As Long, b(5) As Long, i As Integer
For i = 1 To 10 输入数据
a(i) = InputBox("请输入第" & i & "个数", "整数输入")
Next i
For i = 1 To 10 '显示调换前的数据
Text1.Text = Text1.Text & vbCrLf & "a(" & i & ") =" & a(i)
Next i
For i = 1 To 5 '数据调换
b(i) = a(i)
a(i) = a(i + 5)
a(i + 5) = b(i)
Next i
For i = 1 To 10 '显示调换后的数据
Text2.Text = Text2.Text & vbCrLf & "a(" & i & ") =" & a(i)
Next i
End Sub
应该是这样的吧:
var a:array[0..10] of integer;
i,temp:integer;
begin
for i:=1 to 10 do
read(a[i]);
for i:=1 to 5 do
temp:=a[i];
a[i]:=a[11-i];
a[11-i]:=temp;
end;
for i:=1 to 10 do
write(a[i];
writeln;
end.