#include <stdio.h>
#include <stdlib.h>
#include <
malloc.h>
typedef struct LinkList
{
int data;
struct LinkList *
next;
}NODE;
NODE*
Create_List()
{
int n;
NODE *p,*r,*L=(NODE*)
malloc(
sizeof(NODE*
));
L->data=
0;
L->next=
NULL;
r=
L;
scanf("%d",&
n);
while(
1)
{
if(n<
0)
break;
p=(NODE*)
malloc(
sizeof(NODE*
));
p->data=
n;
p->next=r->
next;
r->next=
p;
r=
p;
scanf("%d",&
n);
}
return L;
}
void Display_List(NODE *
L)
{
if(L->next!=
NULL)
Display_List(L->
next);
printf("%d ",L->
data);
}
void Find_Node(NODE *
L)
{
int i,j=
0;
NODE *p=
L;
printf("请输入要查找节点的位置:");
scanf("%d",&
i);
for(i,j;j<i;j++
)
p=p->
next;
printf("所查找节点的值为:%d\n",p->
data);
}
void main ()
{
NODE *
head;
head=
Create_List();
Find_Node(head);
printf("链表倒序输出如下:\n");
Display_List(head);
}
转载于:https://www.cnblogs.com/919czzl/p/4436928.html
转载请注明原文地址: https://win8.8miu.com/read-17344.html