#include<malloc.h>
#include <stdio.h>
typedef int datatype;
typedef struct LNode{
datatype data;
struct LNode *next;
} *node;
void scan(node&head,int n)//输入
{
head=(node)malloc(sizeof(LNode));
head->next=NULL;
LNode *p;
printf("请输入%d个元素\n",n);
for(int i=n;i>0;--i){
p=(node)malloc(sizeof(LNode));
scanf("%d",&p->data);
p->next=head->next;
head->next=p;
}
}
void display(node &head)//输出
{
LNode *p;
p=head->next;
printf("开始输出单链表各个元素\n");
while(p!=NULL){
printf("->%d",p->data);
p=p->next;
}
printf("\n单链表结束!\n");
}
int len(node &head) {
int i=0;
LNode *p&