#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define N 3
int tmp[N][N] = { 0 };
void arrange(int* p,int i,int j )
{
int* q = NULL;
q = tmp[j];
q += i;
*q = p;
}
int main()
{
int num[N][N] =
{
1,2,3,
4,5,6,
7,8,9
};
int p = NULL;
for (int i = 0;i < N;i++)
{
p = num[i];
for (int j = 0;j < N;j++)
{
arrange(p + j,i,j);
}
}
for (int i = 0;i < N;i++)
{
for (int j = 0;j < N;j++)
{
printf("%d", tmp[i][j]);
}
printf("\n");
}
system(“pause”);
return 0;
}
用指针转置矩阵
最新推荐文章于 2023-05-14 15:10:58 发布