hanyujianke 2019-12-20
10 1 3 22 8 15 999 9 44 6 1001
4 6 22 8 44 6 1 3 15 999 9 1001
#include <stdio.h>
#include <stdlib.h>
struct node
{
int data;
struct node *next;
};
int main()
{
int n,i,a,b,x;
a=b=0;
struct node *head1,*head2,*p,*q,*tail1,*tail2;
scanf("%d",&n);
head1=(struct node *)malloc(sizeof(struct node));
head2=(struct node *)malloc(sizeof(struct node));
head1->next=NULL;
head2->next=NULL;
tail1=head1;
tail2=head2;
for(i=0; i<n; i++)
{
scanf("%d",&x);
if(x%2==0)
{
p=(struct node *)malloc(sizeof(struct node));
p->data=x;
p->next=NULL;
tail1->next=p;
tail1=p;
a++;
}
else
{
q=(struct node *)malloc(sizeof(struct node));
q->data=x;
q->next=NULL;
tail2->next=q;
tail2=q;
b++;
}
}
printf("%d %d\n",a,b);
for(p=head1->next; p!=NULL; p=p->next)
{
if(p->next==NULL)
{
printf("%d\n",p->data);
}
else printf("%d ",p->data);
}
for(p=head2->next; p!=NULL; p=p->next)
{
if(p->next==NULL)
{
printf("%d\n",p->data);
}
else printf("%d ",p->data);
}
return 0;
}