Skip to content

Commit 6790f60

Browse files
Add files via upload
determinant of a matrix
1 parent cd7f52e commit 6790f60

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

math/C++/determinant.cpp

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#define N 4
2+
#include <bits/stdc++.h>
3+
using namespace std;
4+
5+
6+
void getCofactor(int mat[N][N], int temp[N][N], int p, int q, int n)
7+
{
8+
int i = 0, j = 0;
9+
10+
11+
for (int row = 0; row < n; row++)
12+
{
13+
for (int col = 0; col < n; col++)
14+
{
15+
16+
if (row != p && col != q)
17+
{
18+
temp[i][j++] = mat[row][col];
19+
20+
21+
if (j == n - 1)
22+
{
23+
j = 0;
24+
i++;
25+
}
26+
}
27+
}
28+
}
29+
}

0 commit comments

Comments
 (0)