#include<iostream>
using namespace std;
typedef int matriks[100][100];
void input(matriks &A,int n);
void output(matriks A,int n);
void output_matriks(matriks A,matriks B,int n);
void output_matriks2(matriks A,matriks B,int n);
void output_matriks3(matriks A,matriks B,int n);
void input(matriks &A,int n)
{
cout<<"Masukan entri matriks"<<endl<<endl;
for(int i=1;i<=n;i++)
{
for(int j=1;j<=n;j++)
{
cout<<"entri["<<i<<"]["<<j<<"]:";
cin>>A[i][j];
}
}
}
void output(matriks A,int n)
{
cout<<endl<<endl;
cout<<"Output ="<<endl<<endl;
for(int i=1;i<=n;i++)
{
for(int j=1;j<=n;j++)
{
cout<<" "<<A[i][j];
}
cout<<endl;
}
}
void output_matriks(matriks A,matriks B,int n)
{
cout<<endl<<endl;
cout<<"Matriks Penjumlahan="<<endl<<endl;
for(int i=1;i<=n;i++)
{
for(int j=1;j<=n;j++)
{
cout<<" "<<A[i][j]+B[i][j];
}
cout<<endl;
}
}
void output_matriks2(matriks A,matriks B,int n)
{
cout<<endl<<endl;
cout<<"Matriks Pengurangan="<<endl<<endl;
for(int i=1;i<=n;i++)
{
for(int j=1;j<=n;j++)
{
cout<<" "<<A[i][j]-B[i][j];
}
cout<<endl;
}
}
void output_matriks3(matriks A,matriks B,int n)
{
cout<<endl<<endl;
cout<<"Matriks Pengurangan="<<endl<<endl;
for(int i=1;i<=n;i++)
{
for(int j=1;j<=n;j++)
{
cout<<" "<<A[i][j]*B[i][j];
}
cout<<endl;
}
}
int main()
{ matriks A,B;
int n,pilih;
char a='y';
do{
cout<<"Menu : \n";
cout<<"1.Input Matriks \n";
cout<<"2.Cetak Matriks \n";
cout<<"3.Pertambahan\n";
cout<<"4.Pengurangan\n";
cout<<"\nPilih 1-5:";cin>>pilih;
switch(pilih){
case 1:
{
cout<<"Masukan Ordo Matriks :";cin>>n;
cout<<"Input Matriks A:\n";
input(A,n);
cout<<"Input Matriks B:\n";
input(B,n);
}
case 2:
{
output(A,n);
output(B,n);
break;
}
case 3:
{
output_matriks(A,B,n);
break;
}
case 4:
{
output_matriks2(A,B,n);
break;
}
default:
{
cout<<"input yg anda masukan salah , coba lagi";
break;
}
}
cout<<"Ingin melanjutkan ? (y/n) :";cin>>a;
}
while(a=='y');
cout<<"Terimakasih, Program selesai";
return 0;
}
Tidak ada komentar:
Posting Komentar