90/8/24 (21:42) سلام دوست عزیز.این برنامه به زبان C هست اگه به دردتون بخوره. #include <stdio.h> #define MAX 100 void GetMatrix(int,int,int,int); //get two matrix for multiply int a[MAX][MAX]; int b[MAX][MAX]; main() { // extern a[][],b[][]; int ma,pa; //row and column for matrix a int mb,pb; //row and column for matrix b int c[MAX][MAX]; int i,j,sum=0,k=0; printf("plz enter m p for a? "); scanf("%d %d",&ma,&pa); printf("plz enter m p for b? "); scanf("%d %d",&mb,&pb); if(pa!=mb) printf("sorry,you can not multiply matrix a and b\n"); else { GetMatrix(ma,pa,mb,pb); for(i=0;i<ma;++i){ for(j=0;j<pb;++j){ for(k=0;k<ma;++k) sum+=a[i][k]*b[k][j]; c[i][j]=sum; sum=0; } } for(i=0;i<ma;++i){ printf("\n"); for(j=0;j<pb;++j) printf("%-3d ",c[i][j]); } } printf("\n"); getchar(); } void GetMatrix(int ma,int pa,int mb,int pb){ //get matrix // extern a[][],b[][]; int i,j,tmp; printf("enter matrix a\n"); for(i=0;i<ma;++i){ //get matrix a for(j=0;j<pa;++j){ scanf("%d",&a[i][j]); } } printf("ok, now enter matrix b\n"); for(i=0;i<mb;++i){ //get matrix b for(j=0;j<pb;++j){ scanf("%d",&b[i][j]); } } } البته یکم بهم خورده. برای اطلاعات بیشتر به این آدرس مراجعه کنید. http://forum.persiantools.com/t61935.html باتشکر |
1. 90/8/24 (22:26) ضرب ماتریس 8 * 8 همان 8 وزیر است. برو 8وزیر جستجو بزنی تو گوگل ، سورسشو میتونی پیدا کنی. |