Skip to content

Instantly share code, notes, and snippets.

@MiLk
Created October 4, 2011 13:08
Show Gist options
  • Save MiLk/1261602 to your computer and use it in GitHub Desktop.
Save MiLk/1261602 to your computer and use it in GitHub Desktop.
int** sous_matrice(int** mat, int row, int col, int taille)
{
int i, j, k, l;
int **new_mat;
new_mat = malloc(taille * taille * sizeof (int));
i = 0;
k = 0;
while (k < taille)
{
if (k == row)
k++;
j = 0;
l = 0;
while (l < taille)
{
if (l = col)
l++;
new_mat[i][j] = mat[k][l];
j++;
l++;
}
i++;
k++;
}
return new_mat;
}
int det(int** mat, int taille)
{
int i, j, result = 0;
if (taille == 1)
return (mat[0][0]);
else
{
for (i = 0; i < taille; i++)
{
result += mat[0][i] * det(sous_matrice(&mat, 0, i, taille - 1), taille - 1);
}
return result;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment