#include<stdio.h>
#include<malloc.h>
typedef char elemtype;
typedef struct node
{
elemtype ch;
struct node*next;
}Poly;
Poly*GreatPoly(Poly*L)
{
Poly*p,*r;
char a;
int i,n;
int finished=0;
L=(Poly*)malloc(sizeof(Poly));
L->next=L;
r=L;
while(finished==0)
{
printf("请输入一个字符。\n");
p=(Poly*)malloc(sizeof(Poly));
scanf("%c",&p->ch);
p->next=L;
r->next=p;
r=p;
printf("finished=?\n");
scanf("%d",&finished);
}
return L;
}
void Newpoly(Poly*L,Poly*L1,Poly*L2,Poly*L3)
{
Poly*t,*p1,*p2,*p3;
L1=(Poly*)malloc(sizeof(Poly));
L1->ch=0;
L1->next=L1;
L2=(Poly*)malloc(sizeof(Poly));
L2->ch=0;
L2->next=L2;
L3=(Poly*)malloc(sizeof(Poly));
L3->ch=0;
L3->next=L3;
t=L;
p1=L1;
p2=L2;
p3=L3;
while(t->next!=L)
{
if('0'<=t->next->ch<='9')
{
p1->next=t->next;
p1=p1->next;
}
else
{
if('A'<=t->next->ch<='Z'||'a'<=t->next->ch<='z')
{
p2->next=t->next;
p2=p2->next;
}
else
{
p3->next=t->next;
p3=p3->next;
}
}
t=t->next;
}
}
void out(Poly*L)
{
Poly*r;
r=L;
while(r->next!=L)
{
printf("%c ",r->next->ch);
r=r->next;
}
}
main(void)
{
Poly*A,*B,*C,*D;
GreatPoly(A);
Newpoly(A,B,C,D);
out(A);
printf("\n");
out(B);
printf("\n");
out(C);
printf("\n");
out(D);
printf("\n");
}