上一页 1 ··· 4 5 6 7 8 9 10 下一页
  2024年10月28日
摘要: a=[[1,2,3],[4,5,6],[7,8,9]] d=[c for b in a for c in b] print(d) print("学号:2005") 阅读全文
posted @ 2024-10-28 11:37 VVV1 阅读(8) 评论(0) 推荐(0)
摘要: L = ['abc', 12, 3.45, 'Python', 2.789] print(L) #输出完整列表 print(L[0]) #输出列表的第一个元素 L[0] = 'a' #修改列表的第一个元素 L[1:3] = ['b', 'Hello'] #修改列表的第二、三元素 print(L) L 阅读全文
posted @ 2024-10-28 11:34 VVV1 阅读(11) 评论(0) 推荐(0)
摘要: ` import numpy as np a=[] with open('data2_2.txt')as f: for (i,s)in enumerate(f): a.append([s.count('a'),s.count('c'), s.count('g'),s.count('t')]) b=n 阅读全文
posted @ 2024-10-28 11:31 VVV1 阅读(14) 评论(0) 推荐(0)
摘要: `str1 = "Hello World!" print(str1) #输出字符串 print(str1[0:-1]) #输出第一个到倒数第2个的所有字符 print(str1[-1]) #输出字符串的最后一个字符 print(str1[2:5]) #输出从第三个开始到第五个的字符 print(st 阅读全文
posted @ 2024-10-28 11:26 VVV1 阅读(21) 评论(0) 推荐(0)
  2024年10月27日
摘要: `import numpy as np matches = np.array([ [0, 1, 0, 1, 1, 1], # 1队 [0, 0, 0, 1, 1, 1], # 2队 [1, 1, 0, 1, 0, 0], # 3队 [0, 0, 0, 0, 1, 1], # 4队 [0, 0, 1, 阅读全文
posted @ 2024-10-27 23:10 VVV1 阅读(25) 评论(0) 推荐(0)
摘要: `import numpy as np distances = np.array([ [0, 2, 7, np.inf, np.inf, np.inf], [2, 0, 4, 6, 8, np.inf], [7, 4, 0, 1, 3, np.inf], [np.inf, 6, 1, 0, 1, 6 阅读全文
posted @ 2024-10-27 23:07 VVV1 阅读(14) 评论(0) 推荐(0)
摘要: 非赋权图: import networkx as nx import matplotlib.pyplot as plt G = nx.Graph() nodes = ['v1', 'v2', 'v3', 'v4', 'v5', 'v6'] G.add_nodes_from(nodes) edges 阅读全文
posted @ 2024-10-27 23:03 VVV1 阅读(8) 评论(0) 推荐(0)
  2024年10月15日
摘要: import matplotlib.pyplot as plt import numpy as np import cvxpy as cp x=cp.Variable(6,pos=True) obj=cp.Minimize(x[5]) a1=np.array([0.025, 0.015, 0.055 阅读全文
posted @ 2024-10-15 13:35 VVV1 阅读(16) 评论(0) 推荐(0)
  2024年10月14日
摘要: initial_costs = [2.5, 2.6, 2.8, 3.1] salvage_values = [2.0, 1.6, 1.3, 1.1] maintenance_costs = [0.3, 0.8, 1.5, 2.0] dp = [[float('inf')] * 2 for _ in 阅读全文
posted @ 2024-10-14 23:51 VVV1 阅读(12) 评论(0) 推荐(0)
摘要: import heapq def prim(graph, start): num_nodes = len(graph) visited = [False] * num_nodes min_heap = [(0, start, -1)] mst_cost = 0 mst_edges = [] whil 阅读全文
posted @ 2024-10-14 23:49 VVV1 阅读(13) 评论(0) 推荐(0)
上一页 1 ··· 4 5 6 7 8 9 10 下一页