求解啊求解。一个二维数组指针的问题。真心找不到问题(╯﹏╰)b
#include<stdio.h>int main()
{
int a[3][3],i;
void move(int **p);
printf("enter the number:\n");
for(i=0;i<3;i++)
scanf("%d% %d %d",&a[i][0],&a[i][1],&a[i][2]);
for(i=0;i<3;i++)
printf("%d %d %d",a[i][0],a[i][1],a[i][2]);
p=a
move(p);
printf("news numbers are:\n");
for(i=0;i<3;i++)
printf("%d %d %d",a[i][0],a[i][1],a[i][2]);
return 0;
}
void move(int **p)
{
int i,j,t;
for(i=0;i<3;i++)
for(j=0;j<3;j++)
{
t=*(*(p+i)+j);
*(*(p+i)+j)=*(*(p+j)+i);
*(*(p+j)+i)=t;
}
}
654.cpp
C:\Users\Administrator\Desktop\654.cpp(11) : error C2065: 'p' : undeclared identifier
C:\Users\Administrator\Desktop\654.cpp(12) : error C2440: '=' : cannot convert from 'int [3][3]' to 'int'
This conversion requires a reinterpret_cast, a C-style cast or function-style cast
C:\Users\Administrator\Desktop\654.cpp(12) : error C2146: syntax error : missing ';' before identifier 'move'
执行 cl.exe 时出错.
654.exe - 1 error(s), 0 warning(s)