pythonExample100/JCP066.py

20 lines
416 B
Python
Raw Permalink Blame History

This file contains invisible Unicode characters!

This file contains invisible Unicode characters that may be processed differently from what appears below. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to reveal hidden characters.

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

'''
【程序66】
题目输入3个数a,b,c按大小顺序输出。   
1.程序分析:利用指针方法。
2.程序源代码:
'''
if __name__ == '__main__':
n1 = int(raw_input('n1 = :\n'))
n2 = int(raw_input('n2 = :\n'))
n3 = int(raw_input('n3 = :\n'))
def swap(p1,p2):
return p2,p1
if n1 > n2 : n1,n2 = swap(n1,n2)
if n1 > n3 : n1,n3 = swap(n1,n3)
if n2 > n3 : n2,n3 = swap(n2,n3)
print n1,n2,n3