回复 楼主 洪荒
程序没有问题呀,将二维数组行、列倒置以后再与二维数组相加
程序代码:
#include<stdio.h>
int a[3][3] = { 1,2,3,4,5,6,7,8,9 };
int i, n;
void fun(int d[3][3])
{
int b[3][3];
int c[3][3];
for (i = 0;i <= 2;++i)
{
for (n = 0;n <= 2;++n)
{
b[n][i] = d[i][n];
c[n][i] = d[n][i] + b[n][i];
}
}
for (i = 0;i <= 2;++i)
{
for (n = 0;n <= 2;++n)
{
printf("%2d ", d[i][n]);
}
printf("\n");
}
printf("\n");
for (i = 0;i <= 2;++i)
{
for (n = 0;n <= 2;++n)
{
printf("%2d ", b[i][n]);
}
printf("\n");
}
printf("\n");
for (i = 0;i <= 2;++i)
{
for (n = 0;n <= 2;++n)
{
printf("%2d ", c[i][n]);
}
printf("\n");
}
printf("\n");
}
int main()
{
fun(a);
return 0;
}