Advertisement
Guest User

Untitled

a guest
Feb 28th, 2020
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.00 KB | None | 0 0
  1. import numpy as np
  2.  
  3. def how_with_plus(matrix):
  4.     count = 0
  5.     for i in range(len(matrix)):
  6.         positive = 0
  7.         for j in range(len(matrix[0])):
  8.             if matrix[i][j] > 0:
  9.                 positive += 1
  10.         if positive >= 3:
  11.             count += 1
  12.     return count
  13.  
  14. A = np.array([[0, 9, 5, 0, 0, 2], [8, 5, 3, -5, 1, 4], [2, -1, 6, -3, 0, 1], [5, -5, -2, 5, 1, 0]])
  15. size_f_goal = len(A[0]) - 1
  16. min_colm = 1
  17. min_f_goal = A[0][min_colm]
  18. for i in range(size_f_goal):
  19.     if A[0][i] < min_f_goal:
  20.         min_f_goal = A[0][i]
  21.         min_colm = i
  22. size_b = how_with_plus(A)
  23. min_line = 1
  24. min_a = A[min_line][min_colm]
  25. while min_a == 0:
  26.     min_line += 1
  27.     min_a = A[min_line][min_colm]
  28. min_koef = A[min_line][0] / min_a
  29. for i in range(size_b):
  30.     if A[i][min_colm] != 0:
  31.         new_min_koef = A[i][0] / A[i][min_colm]
  32.         if new_min_koef < min_koef:
  33.             min_koef = new_min_koef
  34.             min_line = i
  35. for i in range(size_b):
  36.     A[i][min_line] = A[i][min_colm]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement