刚学的,请教一个链表问题
#include<iostream>
#include<stdlib>
using namespace std;
typedef int elemtype;//定义数据类型
typedef struct linknode
{
elemtype data;
struct linknode *next;
}nodetype;//定义节点类型
nodetype *create()//建立单链表,由用户输入节点data域之值,以0表示输入结束
{
elemtype d;
nodetype *h=NULL,*s,*t;
int i=1;
cout<<"建立一个单链表"<<endl;
while(1)
{
cout<<"输入第"<<i<<"节点data域值:";
cin>>d;
if(d==0)
break;
}
if(i==1)
{
h=(nodetype *)malloc(sizeof (nodetype));
h->data=d;
h->next=NULL;
t=h;
}//建立第一个节点
else
{
s=(nodetype *)malloc(sizeof (nodetype));
s->data=d;
s->next=NULL;
t->next=s;
t=s;
}
i++;
}
return h;
}
void disp(nodetype *h)//输入由h指向的单链表的所有data域之值
{
nodetype *p=h;
cout<<"输入一个单链表:"<<endl<<"";
if(p==NULLL)
cout<<"空表";
while(p!=NULL)
{
cout<<p->data<<"";
p=p->next;
}
cout<<endl;
}
int len(nodetype *h)//返回单链表长度
{
int i=0;
nodetype *p=h;
while(p!=NULL)
{
p=p->next;
i++;
}
return i;
}
nodetype *find(nodetype *h,int i)//返回第i个节点的指针
{
nodetype *p=h;
int j=1;
if (i>len(h)||i<=0)
return NULL;
else
{
while(p!=NULL&&j<i)//查找第j个节点,并由p指向该节点
{
j++;
p=p->next;
}
return p;
}
}
nodetype *ins(nodetype *h,int i,elemtype x)
//在单链表head中第i个节点(i>=0)之后插入一个data域为x的节点
{
nodetype *p,*s;
s=(nodetype *)malloc(sizeof (nodetype));//创建节点e
s->data=x;
s->next=NULL;
if(i==0)
{
s->next=h;
h=s;
}
else
{
p=find(h,i);
if(p!=NULL)
{
s->next=p->next;
p->next=s;
}
else
cout<<"输入的i值不正确"<<endl;
}
return h;
}
nodetype *del(nodetype *h,int i)//删除第i个节点
{
nodetype *p=h,*s;
int j=1;
if (i==1)
{
h=h->next;
free(p);
}
else
{
p=find(h,i-1);
if(p!=NULL&&p->next!=NULL)
{
s=p->next;
p->next=s->next;
free(s);
}
else
cout<<"输入的i值不正确"<<endl;
}
return h;
}
void dispose(nodetype *h)//释放单链表的所有节点空间
{
nodetype *pa=h,*pb;
if(pa!=NULL)
{
pb=pa->next;
if(pb==NULL)//只有一个节点的情况
free(pa);
else//两个以上节点的情况
{
while(pb!=NULL)
{
free(pa);
pa=pb;
pb=pb->next;
}
free(pa);
}
}
}
编译得到的结果如下:
e:\c++源代码\slink.cpp(2) : fatal error C1083: Cannot open include file: 'stdlib': No such file or directory
Error executing cl.exe.
请问那是错在哪里了?谢谢