#include "stdio.h"
#include "stdlib.h"
typedef struct study
{
int data[20];
int last;
}Seqlist;
Seqlist *creat_seqlist()
/*创建线性表*/
{
Seqlist *L;
int x,j=0;
L=malloc(sizeof(Seqlist));
L->last=0;
printf("请输入元素:");
scanf("%d",&x);
while(x!=0)
{
L->data[j]=x;
j++;
L->last++;
scanf("%d",&x);
}
L->last=j+1;
return L;
}
int insert_seqlist(Seqlist *L,int i, int x )
{
int j;
if(iL->last+2){
printf("位置错误!");
return(-1);}
if(L->last=19){
printf("表满!");
return(0);
for(j=L->last;j>=i-1;j--)
L->data[j+1]=L->data[j];
L->data[i-1]=x;
L->last++;
return(1); }
}
intdel_seqlist(Seqlist *L,int x)
/*删除元素*/
{
int i;
if(iL->last+1){
printf("不存在第i个元素!");
return(-1);}
for(i=x;ilast;i++)
L->data[i-1]=L->data;
L->last--;
return(1);
}
int find_seqlist(Seqlist *L,int i)
/*查找元素*/
{
int j=0;
while(jlast&&L->data[j]!=i)
j++;
if(j>L->last)
return(-1);
elsereturn(j);
}
main()
/*程序主函数开始*/
{
struct study *L;
int i,x,j,k,m;
L=creat_list();
printf("input the insert number:");
scanf("%d",&x);
printf("input the location:");
scanf("%d",&i);
insert_list(L,i,x);
printf("input the delete number:");
scanf("%d",&j);
del_list(L,j);
printf("input the number that find:");
scanf("%d",&k);
find_list(L,k);
for(m=0;mlast;m++)
printf("%d",L->data[m]);
}
编译时出现错误:linker error:undefined symbol '_find_list' in moduel biao.c
linker error:undefined symbol '_del_list' in moduel biao.c
linker error:undefined symbol '_insert_list' in moduel biao.c
linker error:undefined symbol '_creat_list' in moduel biao.c
时什么原因呀?
我用的是tc2.01英文版,在编译时出现了错误,还有楼上说我调用函数错误?
我就是想对线性表进行操作:建立、插入、删除、查找
|