#include <iostream.h>
#include <conio.h>
void main ()
{
int x,y,matrik [10][10];
float hasilbagi,det,a,b,c,d;
clrscr ();
cout << "OPERASI MATRIKS MENCARI INVERS MATRIKS \n \n";
for (x=0; x<=1; x++)
{
for (y=0; y<=1; y++)
{
cout << "Elemen Matrik ["<<x<<"] ["<<y<<"]"<<" = "; cin >>matrik [x] [y];
}
}
for (x=0; x<=1; x++)
{
for (y=0; y<=1; y++)
{
cout <<matrik[x][y]<< " ";
}
cout << endl;
}
det = (matrik[0][0] * matrik [1] [1]) - (matrik[1][0] * matrik[0][1]);
cout << endl;
cout << "Determinan matriksnya adalah = ";
cout << det <<endl;
hasilbagi = 1/det;
a = hasilbagi * matrik[1][1];
b = hasilbagi * -matrik[0][1];
c = hasilbagi * -matrik[1][0];
d = hasilbagi * matrik[0][0];
cout<<endl<<"Matriks Invers \n\n="<<"1/"<<det<<" x ["<<matrik[1][1]<<" "<<-matrik[0][1]<<"]";
cout<<"\n ["<<-matrik[1][0]<<" "<<matrik[0][0]<<"]";
cout<<endl;
cout<<"\n Matriks inversnya adalah= \n \n";
cout<<"["<<a<<" "<<b<<"]"<<endl;
cout<<"["<<c<<" "<<d<<"]";
getch();
}
Tidak ada komentar:
Posting Komentar