这个算法与数据结构C语言的编程题,怎么办?

2024-11-18 18:29:50
推荐回答(1个)
回答1:

int insert Pre_seq( PSeqList palist,int p,DataType x)
{
int q;
if (palist->n >=palist -> MAXNUM)
{
printf("Overflow! \n");
return 0;
}

if (p<0 || p>palist->n)
{
printf("Not exist! \n");
return 0;
}
for(q=palist->n-1; q>p; q-- )//改成大于
palist -> element [q +1] = palist ->element [q];
palist ->element [p+1] = x;//改成p+1
palist ->n =palist ->n +1;
return 1;
}
就可以啦