c语言问题~~~

[复制链接]
查看11 | 回复3 | 2009-2-16 23:37:03 | 显示全部楼层 |阅读模式
#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英文版,在编译时出现了错误,还有楼上说我调用函数错误?
我就是想对线性表进行操作:建立、插入、删除、查找

回复

使用道具 举报

千问 | 2009-2-16 23:37:03 | 显示全部楼层
我用vc++6.0编译过了,没问题,只是把c++的换成了c的。 而且功能也都实现了,如果你觉得有问题,可以hi我。#include "stdio.h" #include "stdlib.h" #define Total 5 typedef struct study { int data[Total]; int num; }Seqlist; Seqlist *creat_seqlist() /*创建线性表*/ { Seqlist *L; int x; L=(Seqlist *)malloc(sizeof(Seqlist)); L->num=0; printf("请输入元素:\n"...
回复

使用道具 举报

千问 | 2009-2-16 23:37:03 | 显示全部楼层
#include "stdio.h" #include "stdlib.h" typedef struct study { int data[20]; int last; }Seqlist; Seqlist *creat_seqlist() /*创建线性表*/ {Seqlist *L;int x,j=0; ...
回复

使用道具 举报

千问 | 2009-2-16 23:37:03 | 显示全部楼层
你的函数名是creat_seqlist \ insert_seqlist \ del_seqlist \find_seqlist 而你在main里用的是L=creat_list(); insert_list(L,i,x); del_list(L,j); find_list(L,k);你的函数名不一致啊!!!你定义了creat_seqlist ...
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行