求解答,代码和错误提示如下,不知道如何错的。
#include <iostream>
using namespace std;
void swap(int(*p)[3]){
int i,j;
int temp;
for(i=0;
i<3;
i++) {
for(j=0;
j<3;
j++) {
if(i!=j&&i<j) {
temp=p[i][j];
p[i][j]=p[j][i];
p[j][i]=temp;
}
}
}
int main(){
int(*q)[3]=new int [3][3];
cout<<"输入九个数字"<<endl;
for(i=0;
i<3;
i++) {
for(j=0; j<3; j++) {
cin>>q[i][j];
}
}
cout<<"转置前"<<endl;
for(i=0; i<3; i++) {
for(j=0;j<3; j++) {
cout<<q[i][j]<<" ";
}
cout<<endl;
}
cout<<"开始转置"<<endl;
swap(int(*q)[3]);
delete[] q;
return 0;
}