
#include <iostream>
using namespace std; struct node{
int value;
struct node *next;
}; struct node *head; void insert(struct node * &head,int value)
{
if(head == NULL)
{
head = new struct node;
head->value = value;
head->next = NULL;
return;
} struct node *p = new struct node;
p->value = value;
p->next = NULL; struct node *q = head;
while(q->next != NULL)
{
q = q->next;
} q->next = p; }
void find(struct node *head,int k)
{
if(head == NULL || k <= )
return;
int i = ; struct node *p = head;
while(p != NULL)
{
i++;
if(i == k)
break;
p = p->next;
}
struct node *q = head;
while(p->next != NULL)
{
q = q->next;
p = p->next;
}
cout<<q->value<<endl; } void print(struct node *head)
{
struct node *p = head;
while(p != NULL)
{
cout<<p->value<<" ";
p = p->next;
}
} int main()
{
head = NULL; insert(head,);
insert(head,);
insert(head,);
insert(head,);
insert(head,);
insert(head,);
insert(head,);
insert(head,);
insert(head,);
insert(head,);
insert(head,);
insert(head,);
cout<<"链表:";
print(head);
int k = ;
cout<<"的到数第"<<k<<"个节点为:";
find(head,k); return ;
}