三个数比较大小的算法分析.docxVIP

  • 49
  • 0
  • 约2.28千字
  • 约 6页
  • 2018-02-12 发布于河南
  • 举报
三个数比较大小的算法分析

三个数比较大小的算法分析景宇算法分析#第一种算法 x1=input(“input the first number:”) x2=input(“input the second number:”) x3=input(“input the third number:”) if x1=x2 and x2=x3: max=x1 elif x2=x1 and x2=x3 max=x2 else: max=x3 print(“the max is :”max) 时间复杂度O(1)空间复杂度O(1)#第二种算法 x1=input(“input the first number:”) x2=input(“input the second number:”) x3=input(“input the third number:”) if x1=x2: if x2=x3: max=x1 else: max=x3 else: if x2=x3: max=x2 else: max=x3 print(“the max is :”max) 时间复杂度O(1)空间复杂度O(1)#第三种算法(扩展为 5 个数?) x1=input(“input the first number:”) x2=input(“input the second number:”) x3=input(“

文档评论(0)

1亿VIP精品文档

相关文档