Posted in 面试题 onOctober 09, 2013
解: main()
{
int a[3][3],*p,i;
printf(“Input matrix:\n”);
for(i=0;i scanf(“%d%d%d”,&a[i][0],&a[i][1],&a[i][2]);
p=&a[0][0];
move(p);
printf(“Now,matrix:\n”);
for(i=0;i printf(“%d%d%d\n”,a[i][0],a[i][0],a[i][2]);
}
move(int *pointer)
{ int i,j,t;
for(i=0;i fpr(j=1;j {t=*(pointer+3*i+j);
*(pointer+3*i+j)=*(pointer+3*j+i);
*(pointer+3*j+i)=t;
}
}
{
int a[3][3],*p,i;
printf(“Input matrix:\n”);
for(i=0;i scanf(“%d%d%d”,&a[i][0],&a[i][1],&a[i][2]);
p=&a[0][0];
move(p);
printf(“Now,matrix:\n”);
for(i=0;i printf(“%d%d%d\n”,a[i][0],a[i][0],a[i][2]);
}
move(int *pointer)
{ int i,j,t;
for(i=0;i fpr(j=1;j {t=*(pointer+3*i+j);
*(pointer+3*i+j)=*(pointer+3*j+i);
*(pointer+3*j+i)=t;
}
}
编写函数,将一个3*3矩阵转置
声明:登载此文出于传递更多信息之目的,并不意味着赞同其观点或证实其描述。
Tags in this post...
Reply on: @reply_date@
@reply_contents@