#include <stdio.h>
#define max 10
#define true 1
#define false 0
int insertq(int list[],int*num,int i,int x)
{int j;
if((i<0)||(i>*num+1))
{printf("i is not true");
return(false);
}
if(*num>=max-1)
{printf("the list is full and can't insertq");
return(false);
}
for(j=*num+1;j>i;j--)
list[j]=list[j-1];
list[i]=x;
(*num)++;
return(true);
}
main()
{int i=0,x,*num,ch;
int list[max];
printf("input the list:");
while((ch=getchar())!='/n')
{list[i]=ch;
i++;
}
*num=i-1;
printf("insert no i:");
scanf("%d",&i);
getchar();
printf("insert data");
x=getchar();
getchar();
insertq(list,num,i,x);
for(i=0;i<=*num;i++)printf("list[%d]=%c ",i,list[i]);
printf("/n");
}
#define max 10
#define true 1
#define false 0
int insertq(int list[],int*num,int i,int x)
{int j;
if((i<0)||(i>*num+1))
{printf("i is not true");
return(false);
}
if(*num>=max-1)
{printf("the list is full and can't insertq");
return(false);
}
for(j=*num+1;j>i;j--)
list[j]=list[j-1];
list[i]=x;
(*num)++;
return(true);
}
main()
{int i=0,x,*num,ch;
int list[max];
printf("input the list:");
while((ch=getchar())!='/n')
{list[i]=ch;
i++;
}
*num=i-1;
printf("insert no i:");
scanf("%d",&i);
getchar();
printf("insert data");
x=getchar();
getchar();
insertq(list,num,i,x);
for(i=0;i<=*num;i++)printf("list[%d]=%c ",i,list[i]);
printf("/n");
}