Skip to content
This repository has been archived by the owner on Feb 15, 2024. It is now read-only.

Commit

Permalink
✅ replace-correct-7_003
Browse files Browse the repository at this point in the history
  • Loading branch information
NTGNguyen committed Oct 26, 2023
1 parent becea49 commit 62eb8cd
Showing 1 changed file with 12 additions and 40 deletions.
52 changes: 12 additions & 40 deletions Problem_007/7_003.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,60 +5,32 @@ const int MAX_SIZE = 100;
const int MAXR = 100;
const int MAXC = 100;

bool isFrobeniusMatrix(float matrix[MAX_SIZE][MAX_SIZE], int size)
{
int countNonZeroColumns = 0;

for (int i = 0; i < size; i++)
if (matrix[i][i] != 1)
return false;
for (int i = 0; i < size; i++)
for (int j = 0; j < size; j++)
if (i < j && matrix[i][j] != 0)
return false;
bool isMaTranDonVi(int matrix[MAX_SIZE][MAX_SIZE], int size);
void NhapMaTran(int matrix[MAX_SIZE][MAX_SIZE], int &size);

void NhapMaTran(int matrix[MAX_SIZE][MAX_SIZE], int &size)
{
cin >> size;
for (int i = 0; i < size; i++)
{
int k = 0;
for (int j = 0; j < size; j++)
{
if (j > i && matrix[j][i] != 0)
k++;
cin >> matrix[i][j];
}
if (k != 0)
countNonZeroColumns++;
}
if (countNonZeroColumns > 1)
return false;
return true;
}

void NhapMaTran(float matrix[MAX_SIZE][MAX_SIZE], int size)
bool isMaTranDonVi(int matrix[MAX_SIZE][MAX_SIZE], int size)
{
for (int i = 0; i < size; i++)
{
for (int j = 0; j < size; j++)
{
cin >> matrix[i][j];
if ((i == j && matrix[i][j] != 1) || (i != j && matrix[i][j] != 0))
{
return false;
}
}
}
}

int main()
{
float a[MAXR][MAXC];
int n;
cin >> n;
int m;
cin >> m;
NhapMaTran(a, n);
if (isFrobeniusMatrix(a, n))
{
cout << "Yes";
}
else
{
cout << "No";
}
return 0;
return true;
}

0 comments on commit 62eb8cd

Please sign in to comment.