#include "stdafx.h"
#include "stdio.h"
#include "stdlib.h"
typedef int ElemType;
typedef struct node
{
ElemType data;
struct node next;
}Node;
void CreatList(Node *&L,ElemType a[],int n)
{
Node *s,*r;
int i;
L=(Node *)malloc(sizeof(Node));
r=L;
for(i=0;i {
s=(Node *)malloc(sizeof(Node));
s->data=a[i];
r->next=s;
r=s;
}
r->next=NULL;
}
ElemType num(Node *h)
{
if(h=NULL)
return 0;
else
return(1+num(h->next));
}
int main(int argc, char argv[])
{
Node *L;
ElemType t;
L->next=NULL;
int a[10]={1,2,3,4,5,6,7,8,9,0};
CreatList(L,a,10);
t=num(L->next);
printf("%d",t);
return 0;
}
已经解决啦。。。。。