QBasic编程题!急!

来源:百度知道 编辑:UC知道 时间:2024/05/24 04:46:42
请问学过qb的学姐学长么请教个问题,就是输入三个数把他们的顺序从高到低排列出来,这个程序怎么写啊?谁帮帮?

cls
dim a,b,c as long
input a,b,c
if a<b then swap a,b
if a<c then swap a,c
if b<c then swap b,c
print a;b;c
end

cls
input a,b,c
if a<b then swap a,b
if a>c then
print a
if b>c then print b;c else print c;b
else
print c;a;b
end if
end

cls
input a(1),a(2),a(3)
for a=1 to 3
for b=a to 3
if a(a)<a(b) then swap a(a),a(b)
next b,a
print a(1),a(2),a(3)
end

input n 用处: 输入有“多少个数”“n”
dim a(n)
for i = 1 to n
input a(i) 用处:输入n个数
next i
for i = 1 to n - 1 用处:冒泡排序
for j = i to n
if a(i) < a(j) then 用处:如果前一个数小于后一个数则交换
swep a(i) ,a(j) 用处:交换
end if
next j
next i
for i = 1 to n
print a(i) 用处:打印n个数
next i
我这个可以n个数的顺序从高到低排列出来。
很简单