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
aa3f81d0
authored
Apr 03, 2021
by
BellCodeEditor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
auto save
parent
49bd11e5
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
44 additions
and
29 deletions
test.py
test1.py
test2.py
test.py
deleted
100644 → 0
View file @
49bd11e5
#输入“年月日”,输出是一年中的第几天
## 输入年月日,判断是一年的多少天
def
getN
(
year
,
month
,
day
):
sum
=
0
## 到最后在判断是闰年还是平年
for
i
in
range
(
0
,
month
):
sum
+=
m
[
i
]
sum
+=
day
if
(
year
%
400
==
0
)
or
(
year
%
4
==
0
and
year
%
10
!=
0
):
## 表示是闰年
sum
+=
1
return
sum
year
=
input
(
"year : "
)
## 输出数据
month
=
input
(
"month : "
)
day
=
input
(
"day : "
)
m
=
[
0
,
31
,
28
,
31
,
30
,
31
,
30
,
31
,
31
,
30
,
31
,
30
]
## 只包括前 11 个月
year
=
int
(
year
)
month
=
int
(
month
)
day
=
int
(
day
)
print
(
getN
(
year
,
month
,
day
))
test1.py
View file @
aa3f81d0
#输入n个正整数将其存储到一个列表中,然后从小到大升序排列
#第一步:存储
num_list
=
[]
n
=
int
(
input
(
"请输入
要输入数字的个数:
"
))
n
=
int
(
input
(
"请输入
需要的数字个数:
"
))
for
i
in
range
(
n
):
num
=
int
(
input
(
"输入
第"
+
str
(
i
+
1
)
+
"个数字:
"
))
num
=
int
(
input
(
"输入
的第"
+
str
(
i
+
1
)
+
"个数
"
))
num_list
.
append
(
num
)
for
i
in
range
(
n
):
#冒泡排序:从小到大
for
i
in
range
(
n
-
1
):
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
test2.py
0 → 100644
View file @
aa3f81d0
[
5
,
8
,
6
,
3
,
9
,
2
,
1
,
7
]
#第一轮
[
5
,
6
,
3
,
8
,
2
,
1
,
7
,
9
]
#第二轮
[
5
,
3
,
6
,
2
,
1
,
7
,
8
,
9
]
#第三轮
[
3
,
5
,
2
,
1
,
6
,
7
,
8
,
9
]
#第四轮
[
3
,
2
,
1
,
5
,
6
,
7
,
8
,
9
]
#第五轮
[
2
,
1
,
3
,
5
,
6
,
7
,
8
,
9
]
#第六轮
[
1
,
2
,
3
,
5
,
6
,
7
,
8
,
9
]
#冒泡排序的实现原理
def
b_l
(
l
):
n
=
len
(
l
)
#i表示第几轮
for
i
in
range
(
0
,
n
-
1
):
#j表示列表的下标
for
j
in
range
(
0
,
n
-
1
-
i
):
#比大小
if
l
[
j
]
>
l
[
j
+
1
]:
l
[
j
],
l
[
j
+
1
]
=
l
[
j
+
1
],
l
[
j
]
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