WELCOME TO MY BLOG

TEKNOLOGI DALAM KEHIDUPAN

Jumat, 10 Desember 2010

Program perkalian matrix dengan C++



#include
#include
using namespace std;
int main()
{
int i,j,x,A[4][5],B[5][6],C[4][6];
//INPUT MATRIX A//
cout<<"Matrix A\n"; i=1; while(i<=3) { j=1; while(j<=4) { cout<<"A["<<<"]["<<<"] = "; cin>>A[i][j];
j++;
}

i++;
}
//INPUT MATRIX B//
cout<<"\n\nMatrix B\n"; i=1; while(i<=4) { j=1; while(j<=5) { cout<<"B["<<<"]["<<<"] = "; cin>>B[i][j];
j++;
}

i++;
}
//PROSES//
i=1;
while(i<=3)
{
x=1;
while(x<=5)
{
C[i][x]=0;
j=1;
while(j<=4)
{
C[i][x]=C[i][x]+(A[i][j]*B[j][x]);
j++;
}
x++;
}
i++;
}
//OUTPUT//
cout<<"\nMatrix C\n";
i=1;
while(i<=3)
{
x=1;
while(x<=5)
{
cout<<<" ";
x++;
}
cout<<"\n";
i++;
}
getch();
}

0 komentar:

Posting Komentar

PERSAHABATAN MERUPAKAN SUATU IKATAN YANG BERHARGA..JAGA IKATAN ITU DENGAN SEBAIK BAIKNYA..