Program Matriks Ordo 2x2 ( Dev C++ )
#include <iostream>
#include <conio.h>
using namespace std;
int det,i,j,a,b,c,d,e;
int ax[2][2];
int main(void)
{
cout<<" Input Matriks \n";
cout<< "==============================\n";
for (i=1; i<=2; i++){
for (j=1; j<=2; j++){
cout << "Elemen ["<<i<<"]["<<j<<"] : "; cin >> ax[i][j];
}
}
cout << endl;
cout << " Matriks A \n";
cout << "==============================\n";
for (i=1; i<=2; i++){
for (j=1; j<=2; j++){
cout << " "<<ax[i][j]<<" ";
}
cout << "\n";
}
det = (ax[1][1]*ax[2][2])-(ax[1][2]*ax[2][1]);
cout << "==============================\n";
// invers matriks
e = 1/det;
a = e * ax[2][2];
b = e * -ax[1][2];
c = e * -ax[2][1];
d = e * ax[1][1];
cout << endl ;
cout << "==============================\n";
cout << "determinan matriks = "<<det <<endl;
cout << endl;
cout << "invers matriks = " << endl;
cout << endl;
cout<<" [ " << a << " " << b << " ] "<< endl;
cout<<" [ " << c << " " << d << " ] "<< endl;
cout << "==============================\n";
}
Semoga bermanfaat :)
0 komentar
Posting Komentar