1学习网址
1:地址1
2 链表的创建
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
struct node {
int num;
struct node *next;
};
struct node *create(int n)
{
int i;
struct node *head=NULL;
struct node *mid,*tail;
for(i=n;i>0;i--)
{
mid=(struct node*)malloc(sizeof(struct node));
if(mid==NULL)
{
perror("mid");
exit(-1);
}
scanf("%d",&(mid->num));
if(head==NULL)
head=mid;
else
tail->next=mid;
tail=mid;
}
tail->next=NULL;
return head;
}
int main(int argc,char** argv)
{
int n;
struct node *p;
scanf("%d",&n);
p=create(n);
while(p)
{
printf("%d ",p->num);
p=p->next;
}
printf("\n");
return 0;
}