1. 首页
  2. 编程语言
  3. Python
  4. 计数排序.py(入门级)

计数排序.py(入门级)

上传者: 2021-04-30 00:31:31上传 .PY文件 311.00 Bytes 热度 9次

def count_sort(li,max_count=100): count = [0 for _ in range(max_count 1)] for val in li: count[val] = 1 li.clear() for ind,val in enumerate(count): for i in range(val): li.append(ind)

import randomli = [random.randint(0,100) for _ in range(1000)]#print(li)count_sort(li)print(li)

用户评论