برنامه ماتریس n*n

   

#include "iostream"
using namespace std;
double matrix[100][100];
int c[100];
int n;
double det(int r)
{
int i;
if (r == n)
for (i = 0; i < n; i++)
if (c[i] == 1)
return matrix[n - 1][i];
double s = 0;
int k = 1;
for (i = 0; i < n; i++)
if (c[i] == 1)
{
c[i] = 0;
s += k * matrix[r - 1][i] * det(r + 1);
k = -k;
c[i] = 1;
}
return s;
}
int main()
{
int i, j;
cout << "Enter number of row and col : ";
cin >> n;
for (i = 0; i < n; i++)
for (j = 0; j < n; j++)
{
cout << "Enter member [" << i << "," << j << "] :";
cin >> matrix[i][j];
}
for (i = 0; i < n; i++)
c[i] = 1;
cout << "Determinan Barabar Ast Ba=" << det(1);
cout << endl << endl;
return det(1);
}
/ 0 نظر / 50 بازدید