-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_program2.py
98 lines (82 loc) · 1.79 KB
/
test_program2.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
def ggbabe(a, b):
if a == 0:
res = b
else:
while b != 0:
if a > b:
a = a - b
else:
b = b - a
res = a
#some = res
return res
def fibobabe(p):
if p <= 1:
res = p
else:
a = 0
b = 1
for _ in (1, p, 1):
c = b
b = a + b
a = c
res = b
return res
def bubble_babe(a, l):
for i in (0, l, 1):
for k in (1, l - i, 1):
km1 = k - 1
ak = a[k]
akm1 = a[km1]
if akm1 > ak:
a[km1] = ak
a[k] = akm1
def selection_babe(a, l):
for i in (0, l, 1):
ami = 10000
for k in (i, l, 1):
if a[k] < ami:
mi = k
ami = a[mi]
a[mi] = a[i]
a[i] = ami
def teile_babe(l, links, rechts):
i = links
j = rechts - 1
p = l[rechts]
while i < j:
while i < rechts and l[i] < p:
i = i + 1
while j > links and l[j] >= p:
j = j - 1
if i < j:
tmp = l[i]
l[i] = l[j]
l[j] = tmp
if l[i] > p:
tmp = l[i]
l[i] = l[rechts]
l[rechts] = tmp
return i
def quick_babe(l, links, rechts):
if links < rechts:
t = teile_babe(l, links, rechts)
quick_babe(l, links, t - 1)
quick_babe(l, t + 1, rechts)
def rec_test(a):
if a:
return rec_test(a-1)
return 45
def main():
#a = fibobabe(10)
#b = ggbabe(100, 200)
a = 123456 #[]
# selection_babe(a, 100)
# bubble_babe(a, 100)
quick_babe(a, 0, 99)
# c = rec_test(10)
#t = teile_babe(a, 0, 4)
#i = 0
#while i < 4 and a[i] < 3:
# i = i + 1
#return 500 * 800