#include<stdio.h>
#include<malloc.h>
struct node
{
int data;
struct node *next;
};
int m,b;
struct node *creat(int n)
{
struct node *head,*p;
head=(struct node*)malloc(sizeof(struct node));
head->next=NULL;
for(int i=0;i<n;i++)
{
p=(struct node*)malloc(sizeof(struct node));
scanf("%d",&p->data);
p->next=NULL;
p->next=head->next;
head->next=p;
}
return head;
}
void print(struct node *head)
{
struct node *p=head->next;
while(p!=NULL)
{
if(p->next!=NULL)
{
printf("%d ",p->data);
}
else
printf("%d\n",p->data);
p=p->next;
}
}
struct node *chaifen(struct node *head)
{
struct node *head1,*p,*q;
head1=(struct node*)malloc(sizeof(struct node));
head1->next=NULL;
p=head->next;
head->next=NULL;
q=p->next;
while(p!=NULL)
{
if(p->data%2==0)
{
p->next=head->next;
head->next=p;
b++;
}
else
{
p->next=head1->next;
head1->next=p;
m++;
}
p=q;
if(q!=NULL)
{
q=q->next;
}
}
return head1;
}
int main()
{
int n;
struct node *head1,*head;
scanf("%d",&n);
head=creat(n);
head1=chaifen(head);
printf("%d %d\n",b,m);
print(head);
print(head1);
return 0;
}
#include<malloc.h>
struct node
{
int data;
struct node *next;
};
int m,b;
struct node *creat(int n)
{
struct node *head,*p;
head=(struct node*)malloc(sizeof(struct node));
head->next=NULL;
for(int i=0;i<n;i++)
{
p=(struct node*)malloc(sizeof(struct node));
scanf("%d",&p->data);
p->next=NULL;
p->next=head->next;
head->next=p;
}
return head;
}
void print(struct node *head)
{
struct node *p=head->next;
while(p!=NULL)
{
if(p->next!=NULL)
{
printf("%d ",p->data);
}
else
printf("%d\n",p->data);
p=p->next;
}
}
struct node *chaifen(struct node *head)
{
struct node *head1,*p,*q;
head1=(struct node*)malloc(sizeof(struct node));
head1->next=NULL;
p=head->next;
head->next=NULL;
q=p->next;
while(p!=NULL)
{
if(p->data%2==0)
{
p->next=head->next;
head->next=p;
b++;
}
else
{
p->next=head1->next;
head1->next=p;
m++;
}
p=q;
if(q!=NULL)
{
q=q->next;
}
}
return head1;
}
int main()
{
int n;
struct node *head1,*head;
scanf("%d",&n);
head=creat(n);
head1=chaifen(head);
printf("%d %d\n",b,m);
print(head);
print(head1);
return 0;
}