#include
#define MAXLEN 50
typedef struct{
int elem[MAXLEN];
int last;
}Sqlisttp;
Sqlisttp insert(Sqlisttp V,int i,int b)
{
int j;
if(iV.last+1)
printf("ERROR!");
else if(V.last>=MAXLEN)
printf("OVERFLOW!");
else{
for(j=V.last-1;j>=i-1;j--)
V.elem[j+1]=V.elem[j];
V.elem[i-1]=b;
V.last++;
}
return V;
}
Sqlisttp delet(Sqlisttp V,int i)
{
int j;
if(iV.last) printf("ERROR!");
else{
for(j=i;j
V.elem[j-1]=V.elem[j];
V.last--;
}
return V;
}
void display(Sqlisttp V)
{
int j;
for(j=0;j
printf("%d ",V.elem[j]);
printf("\n");
}
main()
{
Sqlisttp V;
int i,b,j,value;
printf("please input the length:\n");
scanf("%d",&V.last);
printf("\n please input the value:\n");
for(j=0;j
{
scanf("%d",&value);
V.elem[j]=value;
}
printf("\n please input the insert position:");
scanf("%d",&i);
printf("\n please input insert node:");
scanf("%d",&b);
V=insert(V,i,b);
display(V);
printf("\n please input the delete position:");
scanf("%d",&i);
V=delet(V,i);
display(V);
}
#include
#define MAXLEN 50
typedef struct{
int elem[MAXLEN];
int last;
}Sqlisttp;
Sqlisttp insert(Sqlisttp V,int i,int b)
{
int j;
if(iV.last+1)
printf("ERROR!");
else if(V.last>=MAXLEN)
printf("OVERFLOW!");
else{
for(j=V.last-1;j>=i-1;j--)
V.elem[j+1]=V.elem[j];
V.elem[i-1]=b;
V.last++;
}
return V;
}
Sqlisttp delet(Sqlisttp V,int i)
{
int j;
if(iV.last) printf("ERROR!");
else{
for(j=i;j
V.elem[j-1]=V.elem[j];
V.last--;
}
return V;
}
void display(Sqlisttp V)
{
int j;
for(j=0;j
printf("%d ",V.elem[j]);
printf("\n");
}
main()
{
Sqlisttp V;
int i,b,j,value;
printf("please input the length:\n");
scanf("%d",&V.last);
printf("\n please input the value:\n");
for(j=0;j
{
scanf("%d",&value);
V.elem[j]=value;
}
printf("\n please input the insert position:");
scanf("%d",&i);
printf("\n please input insert node:");
scanf("%d",&b);
V=insert(V,i,b);
display(V);
printf("\n please input the delete position:");
scanf("%d",&i);
V=delet(V,i);
display(V);
}