IJUL'S BLOG

Pilihan Menu Matrik

catatan kuliahq:
ni source code menu matrik nya  bro:

#include <iostream.h>
#include <conio.h>
int m1[2][2],m2[2][2];
int input()
{

clrscr();
cout<<"\n Matriks Pertama \n";
for(int i=1;i<=2;i++)
{
for(int j=1;j<=2;j++)
{
cout<<"+ Elemen ["<<i<<","<<j<<"]=";cin>>m1[i][j];
}
}
cout<<"\n Matriks Kedua \n";
for(int x=1;x<=2;x++)
{
for(int y=1;y<=2;y++)
{
cout<<"+ Elemen ["<<x<<","<<y<<"]=";cin>>m2[x][y];
}
}
}

int tampil()
{
clrscr();
cout<<"Matrik Pertama :\n";
for(int i=1;i<=2;i++)
{
for(int j=1;j<=2;j++)
{
cout<<" "<<" ";
cout<<m1[i][j];
}
cout<<"\n";
}
cout<<"\n\n";
cout<<"Matriks Kedua :\n";
for(int x=1;x<=2;x++)
{
for(int y=1;y<=2;y++)
{
cout<<" "<<" ";
cout<<m2[x][y];
}
cout<<"\n";
}
}


int tranpose()
{
tampil();
cout<<"\nTranpose Matriks Pertama :\n ";
for(int i=1;i<=2;i++)
{
for(int j=1;j<=2;j++)
{
cout<<" "<<" ";
cout<<m1[j][i];
}
cout<<"\n";
}
cout<<"\n\n";

cout<<"\nTranpose Matriks Kedua :\n ";

for(int x=1;x<=2;x++)
{
for(int y=1;y<=2;y++)
{
cout<<" "<<" ";
cout<<m2[y][x];
}
cout<<"\n";
}
}

int penjumlahan()
{
int x;
tampil();
cout<<"\nPenjumlahan Matriks \n";
for(int i=1;i<=2;i++)
{
for(int j=1;j<=2;j++)
{
x=m1[i][j]+m2[i][j];
cout<<x;
cout<<" "<<" ";
}
cout<<"\n";
}
}

int perkalian()
{
int C[3][3];
tampil();
cout<<"\nPerkalian Matrik :\n";
for (int i=1;i<=2;i++)
  {
     for (int j=1;j<=2;j++)
     {
     C[i][j]=0;
        for (int k=1;k<=2;k++)
        {
            C[i][j]=C[i][j]+ m1[i][k]*m2[k][j];
        }
     }
  }
  for(i=1;i<3;i++)
  {
     for(int j=1;j<3;j++)
     {
        cout<<C[i][j]<<"\t";
     }
     cout<<endl;
  }
}


void main()
 {
 int kode;
 char pilihan;
 cobalagi:
 cout<< "\tMENU UTAMA\n\n";
 cout<<"1. Memasukkan dua buah matrik\n2. Tampil\n3. Perkalian dua buah matrik\n";
 cout<<"4. Penjumlahan dua buah matrik\n5. Tranpos matrik\n\n";
 cout<<"Pilih menu (1..5): ";
 cin >>kode;
 switch(kode)
 {
 case 1:
 clrscr();
 input();
 break;
 case 2:
 clrscr();
 tampil();
 break;
 case 3:
 clrscr();
 perkalian();
 break;
 case 4:
 clrscr();
penjumlahan();
 break;
 case 5:
 clrscr();
 tranpose();
 break;
 default:
 clrscr();
 cout<<"Kode Salah";
 break;
 }
 cout<<"\n\nMau Ulangi Lagi...(Y/T)? : ";
  cin>>pilihan;
  if(pilihan == 'y' || pilihan == 'Y')
  {
    clrscr();
    goto cobalagi;
  }
 }
 

0 komentar:

Posting Komentar

Powered By Blogger
Diberdayakan oleh Blogger.

Entri Populer

PENGUNJUNG

Buku Tamu

About Me

Foto Saya
Ijal Ferdi
there is no something special about me,,, but this blog is so special for me......
View my complete profile

Total Tayangan Halaman

Followers