4个回答
展开全部
将三个数字进行排序的VB代码:
Private Sub Form_Click()
Dim a#, b#, c#, x#, y#, z#
i: a = InputBox("请输入a")
b = InputBox("请输入b")
c = InputBox("请输入c")
If a = b Or b = c Or a = c Then
Print "输入数据无法运算,请重新输入"
GoToi
End If
If a < b Then
x = b
If x < c Then
x = c
y = b
z = a
End If Else
x = a
If b > c Then
y = b
z = c
Else
y = c
z = b
End If
End If
Print "自大至小排序为:"; x, y, z
End Sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
i as integer
dim j as integer
dim k as integer
dim m as integer
dim ss as integer
dim var1 as integer
k=5 '要插入5个数字
ss=10'素组原始大小
ReDim a(ss) '重新定义数组大小不保留数据
For i = 0 To ss-1 '模拟一组数 0-9的
a(i) = i
Print a(i) & ",";
Next i
ReDim Preserve a(ss+k) '重新定义数组大小保留原有数据
for k1=0 to k-1 '重复插入数据
m = CInt(InputBox("输入要插入的数:"))
a(ss+k1)=m ‘重复插入数据
next k1
'调整循序
for i=0 to ss+k-1
for j=i to ss+k-1
if a(i)>=a(j) then
var1=a(i)
a(i)=a(j)
a(j)=var1
end if
next j
next i
For i = 0 To ss+k-1
Print a(i) & ",";
Next i
dim j as integer
dim k as integer
dim m as integer
dim ss as integer
dim var1 as integer
k=5 '要插入5个数字
ss=10'素组原始大小
ReDim a(ss) '重新定义数组大小不保留数据
For i = 0 To ss-1 '模拟一组数 0-9的
a(i) = i
Print a(i) & ",";
Next i
ReDim Preserve a(ss+k) '重新定义数组大小保留原有数据
for k1=0 to k-1 '重复插入数据
m = CInt(InputBox("输入要插入的数:"))
a(ss+k1)=m ‘重复插入数据
next k1
'调整循序
for i=0 to ss+k-1
for j=i to ss+k-1
if a(i)>=a(j) then
var1=a(i)
a(i)=a(j)
a(j)=var1
end if
next j
next i
For i = 0 To ss+k-1
Print a(i) & ",";
Next i
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
Private Sub Form_Click()
Dim a, b, c, d As Integer
a = Val(InputBox("a="))
b = Val(InputBox("b="))
c = Val(InputBox("c="))
If a < b Then d = a: a = b: b = d
If b < c Then d = b: b = c: c = d
If a < b Then d = a: a = b: b = d
Print a; b; c
End Sub
Dim a, b, c, d As Integer
a = Val(InputBox("a="))
b = Val(InputBox("b="))
c = Val(InputBox("c="))
If a < b Then d = a: a = b: b = d
If b < c Then d = b: b = c: c = d
If a < b Then d = a: a = b: b = d
Print a; b; c
End Sub
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询