#include <stdio.h>
#include<stdlib.h>
#define MAXSIZE 10
int main(void)
{
int elem=NULL,x,i=0,length=0,e,j;
elem=(int )malloc(MAXSIZEsizeof(int));
if(elemNULL)
{
printf(“elem=NULL error!\n”);
return -1;
}
while(scanf("%d",&x))
{
getchar();
length++;
*(elem+i)=x;
i++;
if(lengthMAXSIZE)
break;
}
getchar();
printf(“length=%d\n”,length);
for(i=0;i<length;i++)
{
printf("%d\n",(elem+i));
}
//
// 元素的插入
printf(“Insert i is //insert a number is\nuse\ni xform\n”);
scanf("%d %d",&i,&x);
if(!(1<=i&&length+1>=i))
{
return -1;
}
for(j=length;j>=i;j–)
{
(elem+j)=(elem+j-1);
}
(elem+i-1)=x;
printf(“length=%d\n”,++length);
for(i=0;i<length;i++)
{
printf("%d\n",(elem+i));
}
///
//元素的删除
printf(“delete a number that i is\n”);
while(scanf("%d",&i)==1)
{
getchar();
if(1<=i&&length>=i)
{
break;
}
else
{
continue;
}
}
e=(elem+i-1);
printf(“delete %d\n”,e);
getchar();
for(j=i-1;j<length-1;j++)
{
(elem+j)=(elem+j+1);
}
printf(“length is %d\n”,–length);
for(i=0;i<length;i++)
{
printf("%d\n",(elem+i));
}
return 0;
}