Def dijkstra(graph, node): """ simulate the dijkstra algorithm in a graph """ distance_to = {} distance_to[node] = 0 distance_path = {} while (distance_to): # in case we have a disjoint graph op_node = min_distance(distance_to) distance_path[op_node] = distance_to[op_node] del distance_to[op_node] for x, x_len in graph[op_node].items(): if x not in distance_path: if x not in distance_to: distance_to[x] = distance_path[op_node] + x_len elif distance_to[x] > distance_path[op_node] + x_len: distance_to[x] = distance_path[op_node] + x_len return distance_path
borisowaew
28.04.2022
5. program untitled; const n=3; var max,i,num: integer; m: array [1..n] of integer; begin max: =-1000; for i: =1 to n do readln(m[i]); for i: =1 to n do begin if ((m[i]> m[i+1]) and (m[i]> max)) then begin max: =m[i]; num: =i; end; end; for i: =1 to n do begin if i< > num then m[i]: =2; end; for i: =1 to n do begin write(m[i]); write(','); end; end.
Ответить на вопрос
Поделитесь своими знаниями, ответьте на вопрос:
60 л.мёда в 9 горшочков 2 видов 4 и 8 литров. сколько горшочков каждого вида?