#include <stdio.h>
#include <stdlib.h>
typedef int DataType;
struct SeqList
{
int MAXNUM;
int n;
DataType * element;
};
typedef struct SeqList *PSeqList;
PSeqList creatNullList_Seq(int m)
{
PSeqList palist = (PSeqList)malloc(sizeof(struct SeqList));
if(palist != NULL)
{
palist -> element = (DataType *) malloc(sizeof(DataType) * m);
if(palist -> element){
palist -> MAXNUM = m;
palist -> n = 0;
return palist;
}
else
free(palist);
}
printf("Out of space!/n");
return NULL;
}
int isNullList_Seq(PSeqList palist)
{
return (palist->n == 0);
}
int locate_Seq(PSeqList palist, DataType x)
{
int q;
for(q = 0; q < palist -> n; q++)
if(palist ->element[q] == x)
return q;
return -1;
}
int insertPre_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 exit!/n");
return 0;
}
for(q = palist -> n - 1; q >= p; q--)
{
palist -> element[q + 1] = palist -> element[q];
}
palist ->element[p] = x;
palist -> n = palist -> n + 1;
return 1;
}
int deleteP_Seq(PSeqList palist, int p)
{
int q;
if(p < 0 || p > palist -> n - 1)
{
printf("Not exist!/n");
return 0;
}
for(q = p; q < palist -> n - 1; q ++)
{
palist -> element[q] = palist -> element[q + 1];
}
palist -> n = palist -> n - 1;
return 1;
}
int main(int argc, char **argv)
{
return 0;
}