#include
void mult_matrices(int a[][3], int b[][3], int result[][3]);
void print_matrix(int a[][3]);
void carpma(int a[][3], int b[][3], int result[][3]);
void cıkarma (int a[][3], int b[][3], int result[][3]);
void bolme(int a[][3], int b[][3], int result[][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];
int i,j,temp;
mult_matrices(p, q, r);
print_matrix(r);
plus(p, q, r);
print_matrix(r);
minus(p, q, r);
print_matrix(r);
divide(p, q, r);
print_matrix(r);
printf("\nMatrix 1:\n");
print_matrix(p);
printf("\nMatrix 2:\n");
print_matrix(q);
printf("\nResult:\n");
print_matrix(r);
clrscr();
for( i=0;i<3;i++) {
for( j=0;j<3;j++)
scanf("%d",&p[i][j]);
}
i=0;
j=0 ;
for(int b=0;b<2;b++){
temp= p[i][j+1];
p[i][j+1]=p[i+1][j];
p[i+1][j]=temp;
i=i+1;
j=j+1;
if(b==1){
i=0;
j=0;
temp=p[i][j+2];
p[i][j+2]=p[i+2][j];
p[i+2][j]=temp;
}
}
printf("\nthe transpose of the matrix is:\n");
for(i=0;i<3;i++){
for(j=0;j<3;j++)
printf("%d\t",p[i][j]);
printf("\n");
}
getch();
}
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 plus(int a[][3], int b[][3], int result[][3])
{
int i, j;
for(i=0; i<3; i++)
{
for(j=0; j<3; j++)
{
result[i][j] = a[i][j] * b[i][j];
}
}
void minus(int a[][3], int b[][3], int result[][3])
{
int i, j;
for(i=0; i<3; i++)
{
for(j=0; j<3; j++)
{
result[i][j] = a[i][j] - b[i][j];
}
}
}
void divide(int a[][3], int b[][3], int result[][3])
{
int i, j;
for(i=0; i<3; i++)
{
for(j=0; j<3; j++)
{
result[i][j] = a[i][j] / b[i][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]);
}
2007-01-18
23:49:55
·
4 answers
·
asked by
Anonymous
in
Programming & Design