#include <stdio.h>
void out(int a[3][3])//形式参数
{
int i,j;
for(i=0;i<3;i++)
{for(j=0;j<3;j++)
printf("%7d",a[i][j]);
printf("\n");
}
printf("\n");
}
void exchange(int a[3][3],int b[3][3])
{
int i,j;
for(i=0;i<3;i++)
for(j=0;j<3;j++)
{
b[j][i]=a[i][j];
}
}
void add(int a[3][3],int b[3][3],int c[3][3])
{
int i,j;
for(i=0;i<3;i++)
for(j=0;j<3;j++)
c[i][j]=a[i][j]+b[i][j];
}
void xx(int a[3][3],int b[3][3],int d[3][3])
{
int i,j,k,s;
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
s=0;
{
for(k=0;k<3;k++)
s=s+a[i][k]*b[k][j];
d[i][j]=s;
}
}
}
void main()
{
int a[3][3]={1,2,3,4,5,6,7,8,9};
int b[3][3];
int c[3][3];
int d[3][3];
out(a);//实际参数 数组传递的是地址
exchange(a,b);
out(b);
add(a,b,c);
out(c);
xx(a,b,d);
out(d);
}
转载于:https://www.cnblogs.com/moshuxie/archive/2013/05/10/3071149.html