- 博客(8)
- 收藏
- 关注
原创 Python 快速排序,代码实现
快速排序,代码实现# 基线条件为数组为空或者只包含一个元素def quickSort(array): # 基线条件为数组为空或者只包含一个元素 if len(array) < 2: return array else: # 递归条件 pivot = array[0] less = [] # 小于等于基准值的元素放入less greater = [] # 大于基准值得元素放入greate
2022-04-16 16:28:15
1072
原创 Python sum函数(递归)
Python sum函数(递归)mylist = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]def sumList(mylist): if len(mylist) == 0: return 0 return mylist[0] + sumList(mylist[1:])print(sumList(mylist))'''基线条件:list为空时return 0递归条件:sum = head list + sum (tail list)
2022-04-16 10:02:18
1115
原创 Python 找出列表中最大值(递归)
如果列表为空返回 0;如果列表不为空比较mylist[0] > getMaxValue(mylist[1:]);如果mylist[0]大则返回;否则再次递归;# 处理用列表mylist = [12, 5, 23, 100, 25, 36, 78, 25, 100, 13]# 求最大值函数def getMaxValue(mylist): # 结束条件 if mylist == None: return 0 elif len(myli
2022-04-16 09:40:15
8735
原创 简单的学生管理
# 数据结构class Student: def __init__(self, name, age, score, id=0): self.name = name self.age = age self.score = score self.id = id# 操作控制class Manage: # 学号 __init_id = 1000 def __init__(self): self...
2022-03-29 14:08:17
508
原创 二维数组取值算法
# 操作数组mylist = [ ['00', '01', '02', '03'], ['10', '11', '12', '13'], ['20', '21', '22', '23'], ['30', '31', '32', '33']]# 取值坐标class Vector: def move(self, x, y): pass# x坐标增加class VectorUpX(Vector):...
2022-03-29 13:25:33
1122
原创 Java 构造方法链
public class Faculty extends Employee1{ public static void main(String[] args) { new Faculty(); } public Faculty(){ System.out.println("儿子"); }}class Employee1 extends Person{ public Employee1(){ System.out.p.
2022-03-27 13:35:07
778
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人