单链表的建立
#include<stdio.h>
#include <string.h>
#include <conio.h>
#include<iostream> //标准c++输入/输出
using namespace std; //使用std命名空间
//以上为标准头文件等
//编程实现单链表的建立
typedef struct student{
int data;
struct student *next;
}node;
node *creat()
{
node *head,*p,*s;
int x cycle=1;
head=(node *)malloc(sizeof(node));
p=head;
while (cycle)
{
printf("\n please insert the data:");
scanf("%d",&x);
if (x!=0)
{
s=(node *)malloc(sizeof(node));
s->data=x;
p->next=s;
p=s;
}
else cycle=0
}
head=head->next;//头指针指向第二个元素
p->next=NULL;
return(head);
}