C++ Menghitung Determinan Matriks

//lh3.googleusercontent.com/-K5UKWzgJhmU/AAAAAAAAAAI/AAAAAAAACdI/CN3nwiBZsGE/s512-c/photo.jpg
November 19, 2016





kita bisa memilih matriks 2*2  dan 3*3 dan tampilannya sesuai dengan gambar di samping

 #include<iostream>
#include<conio.h>
#include<stdlib.h>
using namespace std;
main()
{
 int pilihan;
 cout<<"**********MENGHITUNG DETERMINAN MATRIKS***********";
 cout<<"1. Matriks 2x2";
 cout<<"2. Matriks 3x3";
 cout<<"Ketik exit untuk keluar";
 cout<<"Pilihan Anda [1..2..exit]=";
 cin>>pilihan;
 if (pilihan==1)
 {
  int a,b,c,d;
  cout<<"Masukan Elemen Matriks =";
  cout<<"Elemen Matrik Baris 1 Kolom 1 =";
  cin>>a;
  cout<<"Elemen Matrik Baris 1 Kolom 2 =";
  cin>>b;
  cout<<"Elemen Matrik Baris 2 Kolom 1 =";
  cin>>c;
  cout<<"Elemen Matrik Baris 2 Kolom 2 =";
  cin>>d;
  cout<<"Matriks x "<<a<<" "<<b<<endl;
  cout<<"    "<<c<<" "<<d<<endl<<endl;
  cout<<"Determinan Matriks x ="<<(a*d)-(b*c);
 }
 else if (pilihan==2)
 {
  int a,b,c,d,e,f,g,h,i;
  cout<<"Masukan Elemen Matriks =";
  cout<<"Elemen Matrik Baris 1 Kolom 1 =";
  cin>>a;
  cout<<"Elemen Matrik Baris 1 Kolom 2 =";
  cin>>b;
  cout<<"Elemen Matrik Baris 1 Kolom 3 =";
  cin>>c;
  cout<<"Elemen Matrik Baris 2 Kolom 1 =";
  cin>>d;
  cout<<"Elemen Matrik Baris 2 Kolom 2 =";
  cin>>e;
  cout<<"Elemen Matrik Baris 2 Kolom 3 =";
  cin>>f;
  cout<<"Elemen Matrik Baris 3 Kolom 1 =";
  cin>>g;
  cout<<"Elemen Matrik Baris 3 Kolom 2 =";
  cin>>h;
  cout<<"Elemen Matrik Baris 3 Kolom 3 =";
  cin>>i;
  cout<<"Matriks x "<<a<<" "<<b<<" "<<c<<endl;
  cout<<"    "<<d<<" "<<e<<" "<<f<<endl;
  cout<<"    "<<g<<" "<<h<<" "<<i<<endl<<endl;
  cout<<"Determinan Matriks x ="<<(a*e*i+b*f*g+c*d*h)-(c*e*g+b*d*i+a*f*h);
 }
 else
 {
  exit;
 }
}


Related Post

SUBSCRIBE TO OUR NEWSLETTER

closed