Latest News

Membuat Menu Matrix Dalam C++

Menu matrix ini berisi matrix input, tampilan, penjumlahan, pengurangan, determinan, dan tranpose.

Coding dari menu matrix:

#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];
}
}
return 0;
}

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";
}
return 0;
}

int determinan()
{
int det1,det2;
tampil();
det1=-(m1[1][1]*m1[2][2])-(m1[1][2]*m1[2][1]);
cout<<"\n* determinan matriks 1 : "<<det1<<"\n";
det2=-(m2[1][1]*m2[2][2])-(m2[1][2]*m2[2][1]);
cout<<"\n* determinan matriks 2 : "<<det2;
return 0;
}

int tranpose()
{
tampil();
cout<<"\n* tranpose 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<<"\n* tranpose matriks kedua :\n ";

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

int penjumlahan()
{
int x;
tampil();
cout<<"\n* penjumlahan 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";
}
return 0;
}

int pengurangan()
{
int x;
tampil();
cout<<"\n* pengurangan 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";
}
return 0;
}

main()
{
int pil;
pil=1;

while(pil!=7){
clrscr();
cout<<"\n========MENU UTAMA==========\n";
cout<<"1. input matriks\n";
cout<<"2. tampilkan matriks\n";
cout<<"3. penjumlahan\n";
cout<<"4. pengurangan\n";
cout<<"5. determinan\n";
cout<<"6. tranpose\n";
cout<<"7. keluar\n";
cout<<"============================\n";
cout<<"pilihan anda : ";cin>>pil;
switch(pil){
case 1:{
input();break;
}
case 2:{
tampil();break;
}
case 3:{
penjumlahan();break;
}
case 4:{
pengurangan();break;
}
case 5:{
determinan();break;
}
case 6:{
tranpose();break;
}
}
getch();
}
return 0;
}

-Semoga Berguna-^_^
Gammaz77

1 comment:

  1. kita juga punya nih jurnal mengenai matriks, silahkan dikunjungi dan dibaca , berikut linknya
    http://repository.gunadarma.ac.id/bitstream/123456789/4864/1/DOKUMEN%20PRESENTASI.pdf
    semoga bermanfaat yaa :)

    Balas

    ReplyDelete

FOLLOW
Pasang iklan di sini yukk

Punya_FX ^^ Designed by Templateism.com Copyright © 2014

Theme images by Bim. Powered by Blogger.