Jumat, 12 Oktober 2012

Program Invers Matrik Gauss Jordan (2x2) Borland

SOURCE CODE:

#include<iostream.h>
#include<conio.h>

void main()
{
char pil_pro;
float a11, a21, a12, a22, A11=1, A21=0, A12=0, A22=1;
float b11, b21, b12, b22, B11, B21, B12, B22;
float c11, c21, c12, c22, C11, C21, C12, C22;
float d11, d21, d12, d22, D11, D21, D12, D22;
float e11, e21, e12, e22, E11, E21, E12, E22;

cout<<"\n\t\t\tPROGRAM INVERS MATRIKS GAUSS JORDAN "<<endl;
cout<<"\t\t==========================================="<<endl<<endl;

ulang_masuk:
cout<<"\t(1,1) : ";
cin>>a11;
cout<<"\t(1,2) : ";
cin>>a21;
cout<<"\t(2,1) : ";
cin>>a12;
cout<<"\t(2,2) : ";
cin>>a22;

cout<<""<<endl;
cout<<"    ------------------"<<endl<<endl;
cout<<"\t["<<a11<<"\t"<<a21<<"]"<<endl;
cout<<"\t["<<a12<<"\t"<<a22<<"]"<<endl<<endl;
cout<<"    ------------------"<<endl;
cout<<"\n[R] Repeat Input Number  [N] Next Process   |   Choose  :  ";
cin>>pil_pro;
if (pil_pro=='R' || pil_pro=='r')
    {goto ulang_masuk;}
else if (pil_pro=='N' || pil_pro=='n')
    {goto next_satu;}
else
    {goto end;}

//langkah pertama
next_satu:
ulang_satu:
cout<<""<<endl<<endl<<endl<<endl;
cout<<"\t|----------|"<<endl;
cout<<"\t|First Step|"<<endl;
cout<<"\t|----------|"<<endl<<endl;
cout<<"\t["<<a11<<"\t"<<a21<<" | "<<A11<<"\t"<<A21<<"]"<<endl;
cout<<"\t["<<a12<<"\t"<<a22<<" | "<<A12<<"\t"<<A22<<"]"<<endl<<endl;
cout<<"\tChange Column 1 and Row 1 become = 1"<<endl<<endl;
//hasil pertama
b11=a11/a11;b21=a21/a11;B11=A11/a11;B21=A21/a11;
b12=a12;b22=a22;B12=A12;B22=A22;
cout<<"\tResult : "<<endl;
cout<<"\t------"<<endl;
cout<<"\t["<<b11<<"\t"<<b21<<"|\t"<<B11<<"\t"<<B21<<"]"<<endl;
cout<<"\t["<<b12<<"\t"<<b22<<"|\t"<<B12<<"\t"<<B22<<"]"<<endl;
cout<<"\n\n\t[ R ] Repeat     [ N ] Next   |   Choose Process :  ";
cin>>pil_pro;
if (pil_pro=='R' || pil_pro=='r')
    {goto ulang_satu;}
else if (pil_pro=='N' || pil_pro=='n')
    {goto next_dua;}
else
    {goto end;}


//langkah kedua
ulang_dua:
next_dua:
cout<<""<<endl<<endl<<endl<<endl;
cout<<"\t|-----------|"<<endl;
cout<<"\t|Second Step|"<<endl;
cout<<"\t|-----------|"<<endl<<endl;
cout<<"\tChange Column 2 and Row 2 become = 1"<<endl<<endl;
c11=b11;c21=b21;C11=B11;C21=B21;
c12=(b11*(-b12))+b12;c22=(b21*(-b12))+b22;
C12=(B11*(-B12))+B12;C22=(B21*(-B12))+B22;
cout<<"\tResult : "<<endl;
cout<<"\t--------"<<endl;
cout<<"\t["<<c11<<"\t"<<c21<<" | "<<C11<<"\t"<<C21<<"]"<<endl;
cout<<"\t["<<c12<<"\t"<<c22<<" | "<<C12<<"\t"<<C22<<"]"<<endl;
cout<<"\n\n\t[ R ] Repeat     [ N ] Next   |   Choose Process :  ";
cin>>pil_pro;
if (pil_pro=='R' || pil_pro=='r')
    {goto ulang_dua;}
else if (pil_pro=='N' || pil_pro=='n')
    {goto next_tiga;}
else
    {goto end;}

ulang_tiga:
next_tiga:
cout<<""<<endl<<endl<<endl<<endl;
cout<<"\t|----------|"<<endl;
cout<<"\t|Third Step|"<<endl;
cout<<"\t|----------|"<<endl<<endl;
cout<<"\tChange Column 3 and Row 3 become = 1"<<endl<<endl;
d11=c11;d21=c21;D11=d11;D21=C21;
d12=c12/c22;d22=c22/c22;D12=C12/c22;D22=C22/c22;
cout<<"\tResult : "<<endl;
cout<<"\t------"<<endl;
cout<<"\t["<<d11<<"\t"<<d21<<" | "<<D11<<"\t"<<D21<<"]"<<endl;
cout<<"\t["<<d12<<"\t"<<d22<<" | "<<D12<<"\t"<<D22<<"]"<<endl;
cout<<"\n\n\t[ R ] Repeat     [ N ] Next   |   Choose Process :  ";
cin>>pil_pro;
if (pil_pro=='R' || pil_pro=='r')
    {goto ulang_tiga;}
else if (pil_pro=='N' || pil_pro=='n')
    {goto next_empat;}
else
    {goto end;}


ulang_empat:
next_empat:
cout<<""<<endl<<endl<<endl<<endl;
cout<<"\t|-----------|"<<endl;
cout<<"\t|Fourth Step|"<<endl;
cout<<"\t|-----------|"<<endl<<endl;
cout<<"\tChange Column 4 and Row 4 become = 1"<<endl<<endl;
e11=(d12*(-d11))+d11;e21=(d22*(-d12))+d21;
E11=(D12*(-d11))+d11;E21=(d22*(-d21))+D11;
e12=d12;e22=d22;E12=D12;E22=D22;
cout<<"\tSo, the result is : "<<endl;
cout<<"\t------------------"<<endl;
cout<<"\t["<<e11<<"\t"<<e21<<" | "<<E11<<"\t"<<E21<<"]"<<endl;
cout<<"\t["<<e12<<"\t"<<e22<<" | "<<E12<<"\t"<<E22<<"]"<<endl;

end:
cout<<""<<endl<<endl<<endl;
cout<<"\t\t\tThank You"<<endl;
getche ();
}



PRINT SCREEN:




Download Source Code in HERE