|
|
səhifə | 5/5 | tarix | 06.10.2023 | ölçüsü | 249,14 Kb. | | #152748 |
| 2-ma\'ruza (1)
Dastur kodi quyidagicha bo’ladi.
#include
using namespace std;
#define N 4
int determinantOfMatrix(int mat[N][N], int n)
{
int num1, num2, det = 1, index,
total = 1;
int temp[n + 1];
for (int i = 0; i < n; i++)
{
index = i;
while (index < n && mat[index][i] == 0)
{
index++;
}
if (index == n) {
continue;
}
if (index != i)
{
for (int j = 0; j < n; j++)
{
swap(mat[index][j], mat[i][j]);
}
det = det * pow(-1, index - i);
}
for (int j = 0; j < n; j++)
{
temp[j] = mat[i][j];
}
for (int j = i + 1; j < n; j++)
{
num1 = temp[i];
num2 = mat[j][i];
for (int k = 0; k < n; k++)
{
mat[j][k]
= (num1 * mat[j][k]) - (num2 * temp[k]);
}
total = total * num1; }
}
for (int i = 0; i < n; i++)
{
det = det * mat[i][i];
}
return (det / total); }
int main()
{
int mat[N][N] = { { 1, 0, 2, -1 },
{ 3, 0, 0, 5 },
{ 2, 1, 4, -3 },
{ 1, 0, 5, 0 } };
cout<<"Determinant of the matrix is :"<<
determinantOfMatrix(mat, N);
return 0;
}
Takrorlash uchun savol va topshiriqlar
Takrorlanish operatorlarini tushuntirib bering
Integralni to’g’ri to’rtburchaklar usulida taqribiy hisoblashni tushuntirib bering
Integralni to’g’ri trapetsiya usulida taqribiy hisoblashni tushuntirib bering
Integralni to’g’ri Simpson usulida taqribiy hisoblashni tushuntirib bering
Integralni taqribiy hisoblashni usullarini tahlil qiling
Matritsalarni ko’paytirish algorimtlarini tushuntirib bering
Dostları ilə paylaş: |
|
|