parent
98b25b051b
commit
7a86f7d30a
@ -0,0 +1,35 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
"""
|
||||
Created on Thu Apr 10 10:07:35 2025
|
||||
|
||||
@author: LENOVO
|
||||
"""
|
||||
import random
|
||||
N = int(input())
|
||||
random.seed(7)
|
||||
ls = [random.randint(1,100) for x in range(N)]
|
||||
ls1 = ls.copy()
|
||||
for i in range(N-1):
|
||||
for j in range(N-1-i):
|
||||
if ls1[j]>ls1[j+1]:
|
||||
#temp = ls1[j+1]
|
||||
ls1[j+1] = ls1[j]
|
||||
ls1[j] = ls1[j+1]
|
||||
print(ls,"\n排序后为:",ls1)
|
||||
|
||||
#杨辉三角
|
||||
n = int(input())
|
||||
ls = []#二维列表
|
||||
for i in range(n):
|
||||
line = [1]
|
||||
if i == 0:
|
||||
ls.append(line)
|
||||
print(ls[i])
|
||||
continue
|
||||
for j in range(1,i):
|
||||
line.append(ls[i-1][j-1]+ls[i-1][j])
|
||||
line.append(1)
|
||||
ls.append(line)
|
||||
print(ls[i])
|
||||
|
||||
|
Loading…
Reference in new issue