Загрузка...

Solve this problem, I will be very grateful

Thread in Python created by toxicity Dec 6, 2019. 241 view

  1. toxicity
    toxicity Topic starter Dec 6, 2019 токсик 467 Sep 9, 2018
    Короче, допустим есть нулевая матрица 5x4 и 4 различных массива типа [x,y] - [[1, 2], [3, 4], [2, 3], [1, 4]]. Нужно в каждом столбце матрицы заменить индекс матрицы x-1 На -1, а y-1 на 1.
     
  2. toxicity
    toxicity Topic starter Dec 6, 2019 токсик 467 Sep 9, 2018
    Должно выйти так [IMG]
     
  3. toxicity
    toxicity Topic starter Dec 6, 2019 токсик 467 Sep 9, 2018
    Нужно найти матрицу инцидентности графа
     
  4. oriole
    oriole Dec 6, 2019 был(а) давно
    Code
    a = [[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0]]

    mas = [[1, 2], [3, 4], [2, 3], [1, 4]]

    for i in range(4):
    a[mas[i][0]-1][i] = -1
    a[mas[i][1]-1][i] = 1

    for i in a:
    print(i)
    The post was merged to previous Dec 6, 2019
    с вас 500 $
     
  5. toxicity
    toxicity Topic starter Dec 6, 2019 токсик 467 Sep 9, 2018
    Пасиб, я сделал по-дургому. Хуйня получиласб, главное что работает.
    Code
    v = 0
    for i in range(k):
    array.append([])
    for j in range(z):
    array[i].append(0)
    while True:
    for x, y in mat:
    if x == y:
    array[x-1][y-1] = 2
    v = v + 1
    else:
    array[x-1][v] = -1
    array[y-1][v] = 1
    v = v+1
    break
    The post was merged to previous Dec 6, 2019
    какой же я еблан :facepalm:
     
Loading...
Top