#include
typedef int ElemType;
typedef struct
{
int data[20];
char name[20];
char sex[5];
char job[20];
int weight;
int height;
int length;
}sqlist;
void initlist(sqlist*);
void output(sqlist*);
int main()
{
sqlist list,*L;
L=&list;
initlist(L);
int i,j;
for (i=0;ilength;i++)
{
printf("請輸入第%d個數字\n",i+1);
scanf("%d",&L->data[i]);
}
printf("please input your name:");
gets(L->name);
output(L);
return 0;
}
void initlist(sqlist*L)
{
L->weight=0;
L->height=0;
L->length=&L->data[20]-&L->data[0]+1;
}
int getlen(sqlist*L)
{
return L->length;
}
int getelem(sqlist*L,int i,ElemType *e)
{
if (L->data[i-1]==NULL)
{
printf("The datastruct is NULL\n");
return 0;
}
if (i=L->length)
{
printf("the num is illegal!");
return 0;
}
*e=L->data[i-1];
return 1;
}
int insert(sqlist*L,int i,ElemType x)
{
int j;
if (i>L->length+1)
{
printf("No enough memory!");
return 0;
}
if (i
{
printf("it's illegal!");
return 0;
}
for (j=L->length-1;i>=i-1;j++)
{
L->data[j+1]=L->data[j];
}
L->data[i-1]=x;
return 1;
}
ElemType *delete(sqlist*L,int i,ElemType*e)
{
int j;
if (iL->length)
return 0;
*e=L->data[i-1];
for (j=i;jlength;j++)
{
L->data[i-1]=L->data[i];
}
return e;
}
void output(sqlist*L)
{
int i;
for(i=0;ilength;i++)
{
printf("%-3d",L->data[i]);
}
puts("\n");
puts(L->name);
}
include 後面沒跟東西,for循環裡的ilength是寫錯的吧,格式規范點哦