Commit 62666298 by BellCodeEditor

save project

parent 28416401
Showing with 12 additions and 10 deletions
alist = [88, 75, 72, 82, 90, 85, 78, 91] #定义一个函数sum_numbers()
n=len(alist) #要求这个函数能接收一个名为num的整型参数
for in range(n-1) #要求这个函数能计算1+2+3+……+num的结果
for in range(n-1) def sum_nuber(num):
if alist[j]>alist[j+1]: if num==1:
t=alist[j] return 1
alist[j]=alist[j+1] else:
alist[j+1]=t t=sum_nuber(num-1)+num
print(alist) return t
\ No newline at end of file
r=sum=nuber
print(r)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment