#include <stdio.h>
#include <stdlib.h>
#define N 10
void main()
{
int **pp = malloc(sizeof(int *)*(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");
}
时间: 2024-11-09 05:55:16