VB题:用Inputbox函数输入3个任意整数,按从大到小的顺序输出
3个回答
推荐于2018-04-12
展开全部
前面两位说的是C语言,我上面的那位说的是VB,不过那种方法不是很好!
我介绍一种方法你看看!
我就直接写主程序了(自己定义)!
'Option Base 1 这一句话不能少,加在整个程序前面!
For i = 1 To 3
a(i) = InputBox("请输入一个整数:")
Next i
For i = 1 To 3
m=i
For j = i + 1 To 3
If a(j) < a(m) Then
m=j
End if
Next j
t=a(i)
a(i)=a(m)
a(m)=t
Next i
Print
For i= 1 to 3
Print a(i)
Next i
我介绍一种方法你看看!
我就直接写主程序了(自己定义)!
'Option Base 1 这一句话不能少,加在整个程序前面!
For i = 1 To 3
a(i) = InputBox("请输入一个整数:")
Next i
For i = 1 To 3
m=i
For j = i + 1 To 3
If a(j) < a(m) Then
m=j
End if
Next j
t=a(i)
a(i)=a(m)
a(m)=t
Next i
For i= 1 to 3
Print a(i)
Next i
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
2013-04-04
展开全部
sub main()
on error goto NotInt
dim aa as string
dim a1 as integer
dim a2 as integer
dim a3 as integer
aa=inputbox("请输入第1个任意整数")
a1=cint(aa)
aa=inputbox("请输入第2个任意整数")
a2=cint(aa)
aa=inputbox("请输入第3个任意整数")
a3=cint(aa)
if a1<a2 then
if a1<a3 then
s=cstr(a1)
if a2<a3 then
s=s & "<" & cstr(a2) & "<" & cstr(a3)
else
s=s & "<" & cstr(a3) & "<" & cstr(a2)
end if
else
if a2<a3 then
if a2<a3 then
s=s & "<" & cstr(a2) & "<" & cstr(a3)
else
s=s & "<" & cstr(a3) & "<" & cstr(a2)
end if
end if
end if
else
end if
exit sub
NotInt:
msgbox "您输入的" & aa &"不是整数",64,"请确认"
end sub
on error goto NotInt
dim aa as string
dim a1 as integer
dim a2 as integer
dim a3 as integer
aa=inputbox("请输入第1个任意整数")
a1=cint(aa)
aa=inputbox("请输入第2个任意整数")
a2=cint(aa)
aa=inputbox("请输入第3个任意整数")
a3=cint(aa)
if a1<a2 then
if a1<a3 then
s=cstr(a1)
if a2<a3 then
s=s & "<" & cstr(a2) & "<" & cstr(a3)
else
s=s & "<" & cstr(a3) & "<" & cstr(a2)
end if
else
if a2<a3 then
if a2<a3 then
s=s & "<" & cstr(a2) & "<" & cstr(a3)
else
s=s & "<" & cstr(a3) & "<" & cstr(a2)
end if
end if
end if
else
end if
exit sub
NotInt:
msgbox "您输入的" & aa &"不是整数",64,"请确认"
end sub
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询