标题:For循环解决置换问题
只看楼主
freebirdbo
Rank: 1
等 级:新手上路
帖 子:256
专家分:0
注 册:2005-3-27
 问题点数:0 回复次数:1 
For循环解决置换问题
怎样用 For 循环 怎样解决 交换问题啊?
比如 1 2 3 4
把4和1交换 3和2 交换
2006-03-04 09:50
purana
Rank: 16Rank: 16Rank: 16Rank: 16
来 自:广东-广州
等 级:版主
威 望:66
帖 子:6039
专家分:0
注 册:2005-6-17
得分:0 

Option Explicit

Private Sub Command1_Click()
Dim a(1 To 4) As Integer
Dim t As Integer
Dim i As Integer
a(1) = 1: a(2) = 2
a(3) = 3: a(4) = 4
For i = 1 To 4
Print a(i);
Next
Print
For i = 1 To 2
t = a(5 - i)
a(5 - i) = a(i)
a(i) = t
Next
For i = 1 To 4
Print a(i);
Next
End Sub


我的msn: myfend@
2006-03-04 10:03



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-48356-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.233233 second(s), 8 queries.
Copyright©2004-2025, BCCN.NET, All Rights Reserved