#include <stdio.h>
#include <stdlib.h>
#define N 10
//N *开辟 N-1*的数组
void main()
{
//int *p = malloc(sizeof(int)*N);//p[5]
int **pp = malloc(sizeof(int *)*(2 * N - 1));
//pp[2*N-1]
for (int i = 0; i < N;i++)
{
pp[i] = malloc(sizeof(int )*(N - i));
for (int j = 0;j < N-i;j++)
{
pp[i][j] = j + 1;
printf("%3d", pp[i][j]);
}
printf("\n");
}
for (int i = N; i < 2 * N - 1;i++)
{
pp[i] = malloc(sizeof(int)*(i-N+2));
for (int j = 0; j < i - N + 2; j++)
{
pp[i][j] = j + 1;
printf("%3d", pp[i][j]);
}
printf("\n");
}
system("pause");
}
转载于:https://www.cnblogs.com/lhfen/p/6082280.html