Examples 005: Three Sorted

100 different types of python programming language fun title

Examples 005: Three Sorted

Title input three integers x, y, z, please these three numbers small to large outputs.

Program analysis practice your hand to easily find what sorting algorithm, lazy direct transfer function.

raw=[]
for i in range(3):
    x=int(input('int%d: '%(i)))
    raw.append(x)
for i in range(len(raw)):
    for j in range(i,len(raw)):
        if raw[i]>raw[j]:
            raw[i],raw[j]=raw[j],raw[i]
print(raw)

#调用函数
raw2=[]
for i in range(3):
    x=int(input('int%d: '%(i)))
    raw2.append(x)
print(sorted(raw2))
#解本问题有多种方法,此方法并不是标准答案,读者可以自己尝试各种方法。

If you like my articles, please point slide below a recommended walk, to give me power, oh; Reprinted with permission Please note the name of the source. Then our guest like him .. duck.

Guess you like

Origin www.cnblogs.com/wby-110/p/12512560.html