用VB编写三个数比较大小的程序
任意输入三个整数A,B,C,请按从大到小的顺序排列。例如,A=5,B=2,C=7,则输出:C>A>B....
任意输入三个整数A,B,C,请按从大到小的顺序排列。例如,A=5,B=2,C=7,则输出:C>A>B.
展开
2个回答
展开全部
给你一个通用程序:
private sub form_load()
from1.autoredraw=true
endsub
private sub form_click()
dim Shu(3) as integer,Xu(3) as string,I as integer,J as integer
shu(1)=a:shu(2)=b:shu(3)=c
xu(1)="a":xu(2)="b":xu(3)="c"
for i=1 to 2
for J=I+1 to 3
if shu(i)<shu(j) then
shu(0)=shu(i):xu(0)=xu(i)
shu(i)=shu(j):xu(i)=xu(j)
shu(j)=shu(0):xu(j)=xu(0)
end if
next
next
xu(0)=""
for i=1 to 2
xu(0)=xu(0)+xu(i)
if shu(i)>shu(i+1) then
xu(0)=xu(0)+">"
else
xu(0)=xu(0)+"="
end if
xu(0)=xu(0)+xu(i)
print xu(0)
endsub
private sub form_load()
from1.autoredraw=true
endsub
private sub form_click()
dim Shu(3) as integer,Xu(3) as string,I as integer,J as integer
shu(1)=a:shu(2)=b:shu(3)=c
xu(1)="a":xu(2)="b":xu(3)="c"
for i=1 to 2
for J=I+1 to 3
if shu(i)<shu(j) then
shu(0)=shu(i):xu(0)=xu(i)
shu(i)=shu(j):xu(i)=xu(j)
shu(j)=shu(0):xu(j)=xu(0)
end if
next
next
xu(0)=""
for i=1 to 2
xu(0)=xu(0)+xu(i)
if shu(i)>shu(i+1) then
xu(0)=xu(0)+">"
else
xu(0)=xu(0)+"="
end if
xu(0)=xu(0)+xu(i)
print xu(0)
endsub
展开全部
前面的废话就不写了,直接写主体
if A>B then
if c>a then
Return "A>B>C"
else
if c>b then
return "A>C>B"
else
return "A>B>C"
end if
end if
else
if C>B then
return "C>B>A"
else
if C>A then
return "B>C>A"
else
return "B>A>C"
end if
end if
end if
if A>B then
if c>a then
Return "A>B>C"
else
if c>b then
return "A>C>B"
else
return "A>B>C"
end if
end if
else
if C>B then
return "C>B>A"
else
if C>A then
return "B>C>A"
else
return "B>A>C"
end if
end if
end if
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询
广告 您可能关注的内容 |