1ãç»æä½
struct std{
int num;
int age;
char sex;
}ï¼
2ã顺åºè¡¨
#include<stdio.h>
#include<stdlib.h>
#define maxsize 1024
typedef int datatype;
typedef struct{
datatype data[maxsize];
int last;
}sequenlist;
sequenlist* InitList()
{
sequenlist *L=(sequenlist*)malloc(sizeof(sequenlist));
L->last=0;
return L;
}
int InsertList(sequenlist* L,datatype x,int i)
{
int j;
if(L->last>=maxsize-1)
{
printf("List Overflow!\n");
return 0;
}
else if(i<1||i>L->last+1)
{
printf("Error Insert Place!\n");
return 0;
}
else
{
for(j=L->last;j>=i;--j)
L->data[j+1]=L->data[j];
L->data[i]=x;
++L->last;
return 1;
}
}
int DeleteList(sequenlist* L,int i)
{
int j;
if((i<1)||(i>L->last))
{
printf("Error Delete Place!\n");
return 0;
}
else
{
for(j=i;j<L->last;++j)
L->data[j]=L->data[j+1];
--L->last;
return 1;
}
}
int PrintList(sequenlist* L)
{
int i;
if(L->last<0||L->last>maxsize-1)
{
printf("Error List!\n");
return 0;
}
else if(L->last==0)
{
printf("Empty List!\n");
return 0;
}
else
{
printf("/****Now Printing List...****/\n");
for(i=1;i<=L->last;++i)
printf("data(%d)\t%d\n",i,L->data[i]);
printf("/****Printing Ended!****/\n");
return 1;
}
}
int LengthList(sequenlist* L)
{
return L->last;
}
int LocateList(sequenlist* L,datatype x)
{
int i=1;
for(;i<=L->last;++i)
if(L->data[i]==x) return i;
return 0;
}
void DelNodeList(sequenlist* L,datatype x)
{
int i;
i=LocateList(L,x);
while(i)
{
if(DeleteList(L,i)==0) break;
i=LocateList(L,x);
}
}
追é®æè½å ä½ QQåï¼
追ç736900871