#include<iostream.h>
#include<conio.h>
int a[100][100],b[100][100],i,j,pil;
void input()
{
for(i=1;i<=2;i++)
{
for(j=1;j<=2;j++)
{
cout<<"masukkan elemen matriks A ["<<i<<"]["<<j<<"]";
cin>>a[i][j];
}
}
for(i=1;i<=2;i++)
{
for(j=1;j<=2;j++)
{
cout<<"masukkan elemen matriks B ["<<i<<"]["<<j<<"]";
cin>>b[i][j];
}
}
}
void output()
{
cout<<"\nMatriks A\n");
for(i=1;i<=2;1++)
{
for(j=1;j<=2;j++)
{
cout<<a[i][j]<<" ";
}
cout<<"\n";
}
cout<<"\n Matriks B\n";
for(i=1;i<=2;1++)
{
for(j=1;j<=2;j++)
{
cout<b[i][j]<<" ";
}
cout<<"\n";
}
}
void main()
{
menu :
clrscr();
cout<<"\nMenu";
cout<<"\nInput Matriks";
cout<<"\nKeluar";
cout<<"\nPilihan :"; cin>>pil;
switch(pil)
{
case 1:
clrscr();
input();
getch();
goto menu;
case 2:
clrscr();
output();
cout<<"\nPenjumlahan Matriks\n";
for(i=1;i<=2;i++)
{
for(j=1;j<=2;j++)
{
cout<<a[i][j]+b[i][j]<<" ";
}
cout<<"\n";
}
getch();
goto menu;
case 3:
clrscr();
output();
cout<<"\nPerkalian Matriks\n";
for(i=1;i<=2;i++)
{
for(j=1;j<=2;j++)
{
cout<<a[i][j]*b[i][j]<<" ";
}
cout<<"\n";
}
getch();
goto menu;
case 4:
clrscr();
output();
cout<<"\nPenjumlahan Matriks\n";
for(i=1;i<=2;i++)
{
for(j=1;j<=2;j++)
{
cout<<a[j][i],b[j][i]<<" ";
}
cout<<"\n";
}
getch();
goto menu;
case 5:
break;
default:
cout<<"\nSalah";
getch();
goto menu'
}
}
Tidak ada komentar:
Posting Komentar