English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

2 answers

/* Program MAT_MULT.C
**
** Illustrates how to multiply two 3X3 matrices.
**
**
*/

#include

void mult_matrices(int a[][3], int b[][3], int result[][3]);
void print_matrix(int a[][3]);

void main(void)
{
int p[3][3] = { {1, 3, -4}, {1, 1, -2}, {-1, -2, 5} };
int q[3][3] = { {8, 3, 0}, {3, 10, 2}, {0, 2, 6} };
int r[3][3];

mult_matrices(p, q, r);
print_matrix(r);
}

void mult_matrices(int a[][3], int b[][3], int result[][3])
{
int i, j, k;
for(i=0; i<3; i++)
{
for(j=0; j<3; j++)
{
for(k=0; k<3; k++)
{
result[i][j] = a[i][k] + b[k][j];
}
}
}
}

void print_matrix(int a[][3])
{
int i, j;
for (i=0; i<3; i++)
{
for (j=0; j<3; j++)
{
printf("%d\t", a[i][j]);
}
printf("\n");
}
}

2007-12-06 16:23:07 · answer #1 · answered by viknesh123 1 · 0 1

Are you paying or did you have a more specific question?

2007-12-06 16:06:50 · answer #2 · answered by mdigitale 7 · 0 0

fedest.com, questions and answers