You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
36 lines
732 B
36 lines
732 B
# -*- 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])
|
|
|
|
|