How can I write steps 3 and 4 of this algorithm?


----> Step 3: Cover all zeros with a minimum number of lines
We will now determine the minimum number of lines (horizontal or vertical) that are required to cover all zeros in the matrix. All zeros can be covered using 3 lines.
Because the number of lines required (3) is lower than the size of the matrix (n=4), we continue with Step 4.


----> Step 4: Create additional zeros
First, we find that the smallest uncovered number is 6. We subtract this number from all uncovered elements and add it to all elements that are covered twice. This results in the following matrix:


Hungarian algorithm - Wikipedia


Code:
include<iostream>
#include<stdio.h>
#include<time.h>


#define size 4


using namespace std;
void step2(int mat[][size]);
void step1(int mat[][size]);


int main()
{
	int A[4][4] = { {82,83,69,92 }, { 77,37,49,92 }, { 11, 69, 5, 86 }, { 8,9,98,23 }
};


	srand(time(NULL));


	cout << "-----MATRIX-----" << endl;
	for (int i = 0; i < 4; i++)
	{
		for (int j = 0;j < 4;j++) {


			cout << A[i][j] << "\t";
		}
		cout << endl;
	}
	cout << endl;
	cout << "-----STEP 1-----" << endl;
	step1(A);
	for (int i = 0; i < 4; i++)
	{
		for (int j = 0;j < 4;j++) {


			cout << A[i][j] << "\t";
		}
		cout << endl;
	}
	cout << endl;
	cout << "-----STEP 2-----" << endl;
	step2(A);
	for (int i = 0; i < 4; i++)
	{
		for (int j = 0;j < 4;j++) {


			cout << A[i][j] << "\t";
		}
		cout << endl;
	}


	cout << endl << endl;
	system("pause");
}
void step1(int mat[][size])
{
	
	for (int i = 0; i < size; i++) {


		int minm = mat[i][0];


		for (int j = 1; j < size; j++) {


			
			if (mat[i][j] < minm)
				minm = mat[i][j];
		}
		for (int k = 0; k < size; k++)
		{
			mat[i][k] -= minm;
		}
	}
}
void step2(int mat[][size])
{




	for (int i = 0; i < size; i++) {


		int minm = mat[0][i];


		for (int j = 1; j < size; j++) {


			if (mat[j][i] < minm)
				minm = mat[j][i];
		}
		for (int k = 0; k < size; k++)
		{
			mat[k][i] -= minm;
		}
	}
	
}