虽然勉强写出来,但总感觉思路太差,写起来很废劲。差点把自绕进去(严重怀疑自己的智商呀,隐约记得当初选修C时有个什么冒泡法、选择法,但都忘了怎么个意思)
尽管题目要求不使用列表或排序算法,但我不介意你使用任何方法。可以实现三数排序功能,尽管写出来,大家一起来开拓思路。
代码: 全选
#!/usr/bin/env python
def sort3(x,y,z):
if x < y:
if y < z:
print x,y,z
else:
if z < x:
print z,x,y
else:
print x,z,y
else:
if z < y:
print z,y,x
else:
if z < x:
print y,z,x
else:
print y,x,z
a = float(input('enter the 1st no. a='))
b = float(input('enter the 2nd no. b='))
c = float(input('enter the 3nd no. c='))
print ('a=%f,b=%f,c=%f') % (a,b,c)
print 'from low to lager squence'
sort3(a,b,c)