題目:輸入三個整數(shù)x,y,z悼潭,請把這三個數(shù)由小到大輸出
方法一:
# -*- coding:utf-8 -*-
# l = []
# for i in range(3):
# x = int(raw_input("integer:"))
# l.append(x)
# l.sort()
# print l
方法二:
# -*- coding:utf-8 -*-
# x = int(raw_input("x:"))
# y = int(raw_input("y:"))
# z = int(raw_input("z:"))
# a = {"x":x,"y":y,"z":z}
# for i in sorted(a,key=a.get):
# print i,a[i]
方法三:
# -*- coding:utf-8 -*-
l = []
for i in range(3):
x = int(raw_input("integet:"))
l.append(x)
n = len(l)
for j in range(0,n):
for k in range(j+1,n):
if(l[j] >= l[k]):
tmp = l[j]
l[j] = l[k]
l[k] = tmp
print l