Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Administrator
/
lesson11_1
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
1cab8241
authored
Aug 02, 2023
by
BellCodeEditor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
auto save
parent
e9582570
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
29 additions
and
9 deletions
func.py
test.py
func.py
View file @
1cab8241
total
=
[]
'''
while
True
:
https://blog.csdn.net/qq_43422201/article/details/87278228
unit
=
input
(
"请输入:"
)
'''
if
unit
==
'q'
:
n
=
int
(
input
(
'输入数字:'
))
#输入数字
break
a
=
list
(
range
(
1
,
n
+
1
))
#建立一个列表,存放的是号码数
else
:
total
.
append
(
unit
)
count
=
0
;
#构造一个全局变量,使得其储存每一位报的数
print
(
total
)
while
len
(
a
)
>
1
:
#循环直到列表只剩一个元素
\ No newline at end of file
b
=
a
[:]
#复制列表,为下一步删除做准备
for
i
in
range
(
0
,
len
(
b
)):
#在len(b)的次数中,计数,并去除数
count
+=
1
if
count
%
3
==
0
:
#如果报三,则去除a中的这一位
a
.
remove
(
b
[
i
])
print
(
a
[
0
])
count
=
0
n
=
int
(
input
())
nums
=
list
(
range
(
1
,
n
+
1
))
while
len
(
nums
)
>
1
:
# newnums = copy.deepcopy(nums)
newnums
=
nums
[:]
for
i
in
newnums
:
count
+=
1
if
count
%
3
==
0
:
nums
.
remove
(
i
)
print
(
nums
)
\ No newline at end of file
test.py
0 → 100644
View file @
1cab8241
list_1
=
[
2434
,
45455
,
1
,
0
,
-
523
]
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