Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Administrator
/
level3-lesson13-diy1
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
49bd11e5
authored
Apr 02, 2021
by
BellCodeEditor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
auto save
parent
f5bf03ae
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
33 additions
and
1 deletions
a.py
a1.py
test1.py
a.py
View file @
49bd11e5
import
time
aa
=
time
.
time
()
# print(a)
list1
=
[]
for
a
in
range
(
0
,
1000
):
for
b
in
range
(
0
,
1000
):
list1
.
append
(
0
)
bb
=
time
.
time
()
print
(
bb
-
aa
)
a1.py
0 → 100644
View file @
49bd11e5
'''
#冒泡排序的代码实现原理
def b_s(l):
n = len(l)
#i表示第几轮排序
for i in range(0,n-1):
#j表示列表的下标
for j in range(0,n-1)
#比大小
if l[j]>l[j+1]:
l[j],l[j+1] = l[j+1],l[j]
'''
#输入n个正整数存储到一个列表中,按从小到大排序
num_list
=
[]
n
=
int
(
input
(
"请输入数字个数:"
))
for
i
in
range
(
n
):
num
=
int
(
input
(
"输入第"
+
str
(
i
+
1
)
+
"个数字"
))
num_list
.
append
(
num
)
#冒泡排序
for
i
in
range
(
n
):
for
j
in
range
(
n
-
1
-
i
):
if
num_list
[
j
]
>
num_list
[
j
+
1
]:
num_list
[
j
],
num_list
[
j
+
1
]
=
num_list
[
j
+
1
],
num_list
[
j
]
print
(
num_list
)
print
(
num_list
)
test1.py
View file @
49bd11e5
...
...
@@ -8,5 +8,6 @@ for i in range(n):
for
j
in
range
(
n
-
1
-
i
):
if
num_list
[
j
]
>
num_list
[
j
+
1
]:
num_list
[
j
],
num_list
[
j
+
1
]
=
num_list
[
j
+
1
],
num_list
[
j
]
print
(
num_list
)
print
(
num_list
)
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment