#include <stdio.h>
#include <malloc.h>
int main()
{
int n;
int nCount;
int* Pi;
printf("请输入一个正整数\n");
printf("n = ");
scanf("%d",&n);
if (n < 0)
{
printf("输入错误,请重新输入。\n");
}
int *p = (int *)malloc(n*sizeof(int));
Pi = p;
if (NULL == p)
{
printf("动态分配内存失败。\n");
}
else
{
printf("成功创建%d个整型存储空间\n",n);
}
printf("请任意输入%d整数\n",n);
for (nCount = 0; nCount < n; nCount++)
{
scanf("%d",Pi);
Pi++;
}
printf("输入%d整数如下\n",n);
for (nCount = 0; nCount < n; nCount++)
{
printf("第%d个数为:%d\n",nCount+1,*p++);
}
return 0;
}