#include "datastruct.h"
#include "stdio.h"
#include "stdlib.h"
Linklist creat_nohead_head(Linknode *head)
{
 Linknode *p,*q;
 char ch;
 p=head;
 printf("链表中的元素为连续单个值,请连续输入, 输入$结束!\n");
 while((ch=getchar())!='$')
 {
  q=(Linklist)malloc(sizeof(Linknode));
  q->data=ch;
  if(head=NULL)
  {
   head=(Linklist)malloc(sizeof(Linknode));
   head=q;
   p=q;
   head->next=NULL;
  }
  else
  {
   q->next=p;
   p=q;
  }
 }
 return p;
}
int countnode_nohead_head(Linknode *head)
{
 Linknode *p;
 int count=0;
 if(head==NULL)
  return -1;
 p=head;
 while(p!=NULL)
 {
  printf("%c->",p->data);
  p=p->next;
  count++;
 }
 printf("\n");
 return count;
}
 
void main()
{
 Linknode *head=NULL;
 int count;
 head=creat_nohead_head(head);
 count=countnode_nohead_head(head);
 printf("节点个数为%d",count);
}