vfp 程序编写:输入三个数按大小排序,如何编写?

2024-12-14 10:10:33
推荐回答(2个)
回答1:

clear
input "a=" to a
input "b=" to b
input "c=" to c
if a t=a
a=b
b=t
endif
if a t=a
a=c
c=t
endif
if b t=b
b=c
c=t
endif
?"这三个数由大到小为:" ,a,b,c
return

回答2:

clear
dime a(3)
for i=1 to 3
input "请输入一个数:" to a(i)
endfor
?"降序排列为:"
for i=1 to 2
for j=i+1 to 3
if a(i) k=a(i)
a(i)=a(j)
a(j)=k
endif
endfor
??alltrim(str(a(i)))+" "
endfor
??alltrim(str(a(i)))

此程序适合任意多个数排序,只需要修改相应的数字就行了。