Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 02064d7

Browse files
committed
修改命名与结构,让代码更加 Pythonic
1 parent 07aab8c commit 02064d7

File tree

10 files changed

+27
-247
lines changed

10 files changed

+27
-247
lines changed

‎Sort/BubbleSort.py‎

Lines changed: 0 additions & 29 deletions
This file was deleted.

‎Sort/CountSort.py‎

Lines changed: 0 additions & 22 deletions
This file was deleted.

‎Sort/HeapSort.py‎

Lines changed: 0 additions & 30 deletions
This file was deleted.

‎Sort/InsertSort.py‎

Lines changed: 0 additions & 26 deletions
This file was deleted.

‎Sort/MargeSort.py‎

Lines changed: 0 additions & 31 deletions
This file was deleted.

‎Sort/QuickSort.py‎

Lines changed: 0 additions & 39 deletions
This file was deleted.

‎Sort/SelectionSort.py‎

Lines changed: 0 additions & 18 deletions
This file was deleted.

‎Sort/ShellSort.py‎

Lines changed: 0 additions & 21 deletions
This file was deleted.

‎Sort/__init__.py‎

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,2 @@
11
#!/usr/bin/env python3
22
# -*- coding: utf-8 -*-
3-
4-
'''a test module '''
5-
6-
__author__ = 'EINDEX'

‎Sort/main.py‎

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,47 @@
11
#!/usr/bin/env python3
22
# -*- coding: utf-8 -*-
33

4-
'''测试函数 '''
4+
"""测试函数 """
55
import random
66
import time
77

8-
from Sort.BubbleSort import bubble_sort, bubble_sort_flag
9-
from Sort.CountSort import count_sort
10-
from Sort.HeapSort import heap_sort
11-
from Sort.InsertSort import insert_sort
12-
from Sort.MargeSort import merge_sort
13-
from Sort.QuickSort import quick_sort, qsort
14-
from Sort.SelectionSort import selection_sort
15-
from Sort.ShellSort import shell_sort
8+
from Sort.bubble_sort import bubble_sort, bubble_sort_flag
9+
from Sort.count_sort import count_sort
10+
from Sort.heap_sort import heap_sort
11+
from Sort.insert_sort import insert_sort
12+
from Sort.marge_sort import merge_sort
13+
from Sort.quick_sort import quick_sort, qsort
14+
from Sort.selection_sort import selection_sort
15+
from Sort.shell_sort import shell_sort
1616
import sys
1717

1818
# 开挂 防止栈溢出
1919
sys.setrecursionlimit(99999)
2020

21-
#整数数列
21+
#整数数列
2222
# L = [int(random.uniform(0, 5000)) for x in range(1000)]
2323
# 浮点数列
2424
L = [random.uniform(0, 5000) for x in range(1000)]
25-
2625
current = list(L)
2726
current.sort()
2827

29-
def compile(fun):
28+
29+
def sort_test(fun):
3030
l = list(L)
31-
start=time.time()
31+
start=time.time()
3232
res = fun(l)
3333
over = time.time()
34-
print('time:'+str(over-start),current == res, fun.__name__)
35-
36-
37-
compile(selection_sort)
38-
compile(bubble_sort)
39-
compile(bubble_sort_flag)
40-
compile(insert_sort)
41-
compile(merge_sort)
42-
compile(shell_sort)
43-
compile(quick_sort)
44-
compile(qsort)
45-
compile(heap_sort)
46-
if isinstance(L[0],int):
47-
compile(count_sort)
34+
print('time:'+str(over-start),current == res, fun.__name__)
35+
36+
37+
sort_test(selection_sort)
38+
sort_test(bubble_sort)
39+
sort_test(bubble_sort_flag)
40+
sort_test(insert_sort)
41+
sort_test(merge_sort)
42+
sort_test(shell_sort)
43+
sort_test(quick_sort)
44+
sort_test(qsort)
45+
sort_test(heap_sort)
46+
if isinstance(L[0],int):
47+
sort_test(count_sort)

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /