题目五:输入三个整数x,y,z,请把这三个数由小到大输出。

#!/usr/bin/env python3
# -*- coding: utf-8 -*- """ 题目五:输入三个整数x,y,z,请把这三个数由小到大输出。""" __author__ = 'Fan Lijun' one = eval(input('请输入三个数:'))
two = eval(input('请输入三个数:'))
three = eval(input('请输入三个数:')) #方法一:使用内置排序函数
lst = [one, two, three]
print(lst.sort()) #方法二:我自己写一个,锻炼一下if else
lst2 = [] #获得最小数
def minNumber(one, two, three):
if one < two:
if one < three:
lst2.append(one)
else:
lst2.append(three)
else:
if two < three:
lst2.append(two)
else:
lst2.append(three) def maxNumber(one, two, three):
if one > two:
if one > three:
lst2.append(one)
else:
lst2.append(three)
else:
if two > three:
lst2.append(two)
else:
lst2.append(three)
minNumber(one, two, three)
maxNumber(one, two, three) if lst2[0] == one:
if lst2[1] == two:
lst2.insert(1, three)
else:
lst2.insert(1, two)
elif lst2[0] == two:
if lst2[1] == three:
lst2.insert(1, one)
else:
lst2.insert(1, three)
else:
if lst2[1] == two:
lst2.insert(1, one)
else:
lst2.insert(1, three) print(lst2)

  

最新文章

  1. AlloyTouch与three.js 3D模型交互
  2. Asp.net 配置web.Config 在出错时跳转到相应页面
  3. (App.Current.RootVisual as PhoneApplicationFrame).Navigate(new Uri(&quot;/MainPage.xaml&quot;, UriKind.Relative));
  4. SLP的模块结构
  5. java重写equals方法
  6. LintCode Singleton
  7. CSocket服务器(TCP)
  8. 读书笔记--用Python写网络爬虫01--网络爬虫简介
  9. 表单验证提交——submit与button
  10. 云风:我所偏爱的C语言面向对象编程范式
  11. C# Url编码 HtmlUrl编码
  12. 注意使用 BTREE 复合索引各字段的 ASC/DESC 以优化 order by 查询效率
  13. .10-Vue源码之Watcher(1)
  14. Linux IO 模型
  15. Kotlin 接口
  16. Promise是什么?
  17. spring mvc 的上传图片是怎么实现的?
  18. NoSql的三大基石:CAP理论&amp;BASE&amp;最终一致性
  19. 以ORM的思路来从Excel文件中读取JSON数据列表
  20. 你如何获取浏览器URL中查询字符串中的参数?

热门文章

  1. 【Leetcode】【Medium】3Sum
  2. javascript 随机数 生成 n-m
  3. js中直接调用函数和new函数的区别
  4. php安装扩展redis淌过的坑
  5. Eigen参考资料
  6. linux shell数据重定向
  7. 使用jmeter使用Jenkins发送自定义消息内容
  8. mvc读书笔记
  9. 强类型 和弱类型 c#
  10. sql server 获取存储过程,表值,标量函数的参数