Minggu, 17 Januari 2010

Procedure Perkalian Matriks di C++

//procedur perkalian matrik
void perkalian(){
int i,j,k,x,y,z;
float A[10][10],B[10][10],C[10][10];
cout<<"======================================\n"; cout<<"= Program Perkalian Matrik =\n"; cout<<"======================================\n"; cout<<"=Masuakan Ordo Matrik A (max 10x10 !\n"; cout<<"=Baris matrik I :";cin>>x;
cout<<"=Kolom matrik I :";cin>>y;
cout<<"=Masuakan Ordo Matrik B (max 10x10) !\n"; cout<<"=Baris matrik II :"<>z;
cout<<"======================================\n"; if ( (x>10) || (y>10) || (z>10) ){
gotoxy(20,12);cout<<"Masukan Angka di Bawah 10 !\n"; } else { for (i=1;i<=x;i++){ for (j=1;j<=y;j++){ cout<<"=Elemen Matrik A ["<>A[i][j];
}
}
cout<<"======================================\n"; for (i=1; i<=y; i++){ for (j=1; j<=z; j++){ cout<<"=Elemen Matrik B ["<>B[i][j];
}
}
}

cout<<"======================================\n";

for (i=1; i<=x; i++){
for (j=1; j<=z; j++){
C[i][j]=0;
for (k=1; k<=y; k++){
C[i][j]=C[i][j]+(A[i][k]*B[k][j]);
}
}
}

for (i=1; i<=x; i++){
for (j=1; j<=z; j++){
cout<<"=Elemen Matrik C ["< cout<<"\n";
}
}
cout<<"\n======================================";
}

0 comments:

Posting Komentar

Twitter Delicious Facebook Digg Stumbleupon Favorites More

Enter your email address to subscribe:

Delivered by FeedBurner

 
Design by Free WordPress Themes | Bloggerized by Lasantha - Premium Blogger Themes | SharePoint Demo