#include<stdio.h>
#define elemtype char
struct link
{
elemtype data;
link *next;
};
link *la,*lb,*lc;
link *hcreat()
// 头插法建立单链表
{
link *p,*q;
p=new link;
p->next =NULL;
elemtype i;
printf("请输入链表元素,先进的在末尾,输入#结束\n");
scanf("%c",&i);
while(i!='#')
{
q=new link;
q->next =NULL;
q->data
=i;
q->next =p->next ;
p->next =q;
scanf("%c",&i);
};
return p;
};
void div(link *s)
{
la=new link;lb=new link; lc=new link;
la->next=NULL;lb->next=NULL;lc->next=NULL;
la->data='#';lb->data='#';lc->data='#';
link *p,*hla,*hlb,*hlc;
p=s->next;hla=la;hlb=lb;hlc=lc;
while(p!=NULL)
{
if(((p->data)>='0')&&((p->data)<='9'))
{
hla->next=p;
hla=p;
}
else if(((p->data>='a')&&(p->data<='z'))||((p->data>='A')&&(p->data<='Z')))
{
hlb->next=p;
hlb=p;
}
else
{
hlc->next=p;
hlc=p;
}
};
hla->next=la;
hlb->next=lb;
hlc->next=lc;
};
void print1(link *p)
{
link *q;
q=p->next ;
while((q->next)!=NULL)
{
printf("%c",q->data );
q=q->next;
}
printf("%c",q->data );
return ;
}
void print2(link *p)
{
link *q;
q=p->next;
while(q->next->data!='#')
{
printf("%c",q->data );
q=q->next;
}
printf("%c",q->data );
return ;
}
void main()
{
link *px;
px=hcreat();
print1(px);
div(px);
print2(la);
print2(lb);
print2(lc);
}