# include <stdio.h>
# include <stdlib.h>
//定义结构体
typedef struct node{
int data; //数据域
struct node * next; //指针域
}ElemSN; //将 struct node重命名为 ElemSN
//建链表
ElemSN * CreateLink(int a[],int n)
{
ElemSN *h,*p,*t; //h为头指针
h=NULL; //头指针指向NULL
for(int i=0;i<n;i++){
p = (ElemSN * )malloc(sizeof(ElemSN)); //动态单元分配
p->data = a[i]; //访问数据
p->next = NULL; //访问后继
if(!h)
h=t=p;
else
t=t->next=p;
}
return h;
}
//统计结点个数
int Statistics(ElemSN *h)
{
ElemSN *p;
int n=0;
for(p=h;p;p=p->next)
n++;
return n;
}
int main(void)
{
int n; //n为所需结点数
scanf("%d",&n);
int a[n];
for(int i=0;i<n;i++){
scanf("%d",&a[i]);
}
ElemSN * head;
//正向建链
head = CreateLink(a,n);
//统计结点个数
int m; //m接收 Statistics的返回值
m = Statistics(head);
printf("%d",m);
return 0;
}