用C语言编程实现单链表的建立,插入,删除,按序号查找和按值查找算法。出现的错误,怎么改

#include<stdio.h>#include<stdlib.h>#defineTRUE1#defineFALSE0#defineLENsizeof(linklist... #include <stdio.h>
#include <stdlib.h>
#define TRUE 1
#define FALSE 0
#define LEN sizeof(linklist)

typedef struct node
{
char data;
struct node *next;
}linklist;

//函数声明//
void crtlinked();
void locate_x();
void get_i();
void insert();
void delete_after();
void input_array();
void print_link();
void locate_p();

//全局变量定义//
linklist *head;
char b,x;
linklist *p,*q;
int num;
int i,n;

void main()
{
printf("Creating link_list :\n");
crtlinked();
printf("Print the link list :\n");
print_link();

//查找第五个元素的值//
i=5;
get_i();
printf("Get i=5,the Result is :\n");

//按值查找//
x='b';
printf("Display the result: \n");
printf("Locate x=b,the Result is :\n");
locate_x();

//单链表插入//
printf("\n Insert after p:\n");
locate_p();
b='K';
insert();
print_link();

//单链表删除//
printf("\n Delete after p:\n");
locate_p();
delete_after();
print_link();
}

//建立链表//
void crtlinked()
{
linklist *s;
char ch;
head=NULL;
p=head;
printf("\nPlease input the data(char type) to the list:\n");
printf("If you want to end ,input '#':\n");
scanf("%c",&ch);
while(ch!='#')
{
s=( linklist * )malloc(sizeof(linklist));
s->data=ch;
if (head==NULL)
head=s;
else
p->next=s;
p=s;
scanf("%ch",&ch);
}
p->next=NULL;
}

//按值查找//
void locate_x()
{
if (head==NULL)
printf("The list is empty !\n");
p=head;
while ((p->data!=x)&&(p->next!=NULL))
p=p->next;
if (p->data!=x)
printf("There is no this element\n");
else
printf("There is an element in this list. \n");
}//locate//

//按序号查找//
void get_i()
{
int k;
char val;
if (head==NULL)
printf("This is empty list.\n");
else
{
p=head;
k=1;
while ((k<i)&&(p->next!=NULL))
{
k++;
p->next;
}
if (k==i)
{
val=p->data;
printf("Element=%d",val);
}
else
printf("There is no this element!\n");
}
}//get//

//确定P的指向//
void locate_p()
{
int k=0,k1;
printf("Please in put the position of p:\n");//输入p指向第几个元素//
scanf("%d",&k1);
p=head;
if (head!=NULL)
{
while ((p!=NULL)&&(k<k1))
{
p=p->next;
k++;
}
if (k<k1)
printf("The number is too big or the list is too short !\n");
else
printf("The position of p is %d \n",k1);
}
else
printf("The list is empty !\n");
}//locate_p//

//插入元素//
void insert()
{
linklist *s,*q;
s=(linklist *)malloc(LEN);
s->data=b;
q=head;
while (q->next!=p)
q=q->next;
q->next=s;
s->next=p;
}//insert//

//删除元素//
void delete_after()
{
linklist *r;
r=p->next;
p->next=r->next;
free(r);
}
出现这个
Linking...
1022.obj : error LNK2001: unresolved external symbol "void __cdecl print_link(void)" (?print_link@@YAXXZ)
Debug/1022.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.

1022.exe - 2 error(s), 0 warning(s)
展开
 我来答
卧冬的杂货铺
2012-11-04 · TA获得超过242个赞
知道小有建树答主
回答量:451
采纳率:0%
帮助的人:70万
展开全部
错误的意思是没有写print_link()
GarfieldGCat
2012-11-04 · TA获得超过500个赞
知道小有建树答主
回答量:445
采纳率:92%
帮助的人:275万
展开全部
print_link去哪里了?
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
收起 1条折叠回答
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式