#include<stdio.h>
#include<malloc.h>
struct node
{
int data;
struct node *next;
};
struct node *creat(int n)
{
struct node *head,*p,*tail;
head=(struct node *)malloc(sizeof(struct node));
head->next=NULL;
tail=head;
int i;
for(i=0;i<n;i++)
{
p=(struct node *)malloc(sizeof(struct node));
scanf("%d",&p->data);
p->next=NULL;
tail->next=p;
tail=p;
}
return head;
}
void print(struct node *head,int n)
{
struct node *p;
p=head->next;
int t=n-1;
while(t--)
{
printf("%d ",p->data);
p=p->next;
}
printf("%d\n",p->data);
}
void chai(struct node *head)
{
struct node *head1,*head2,*p,*p1,*p2;
int c=0,d=0;
head1=(struct node *)malloc(sizeof(struct node));
head1->next=NULL;
p1=head1;
head2=(struct node *)malloc(sizeof(struct node));
head2->next=NULL;
p2=head2;
p=head->next;
while(p)
{
if(p->data%2==0)
{
c++;
p1->next=p;
p1=p;
}
else
{
d++;
p2->next=p;
p2=p;
}
p=p->next;
}
printf("%d %d\n",c,d);
print(head1,c);
print(head2,d);
}
int main()
{
int n;
struct node *head;
scanf("%d",&n);
head=creat(n);
chai(head);
return 0;
}
#include<malloc.h>
struct node
{
int data;
struct node *next;
};
struct node *creat(int n)
{
struct node *head,*p,*tail;
head=(struct node *)malloc(sizeof(struct node));
head->next=NULL;
tail=head;
int i;
for(i=0;i<n;i++)
{
p=(struct node *)malloc(sizeof(struct node));
scanf("%d",&p->data);
p->next=NULL;
tail->next=p;
tail=p;
}
return head;
}
void print(struct node *head,int n)
{
struct node *p;
p=head->next;
int t=n-1;
while(t--)
{
printf("%d ",p->data);
p=p->next;
}
printf("%d\n",p->data);
}
void chai(struct node *head)
{
struct node *head1,*head2,*p,*p1,*p2;
int c=0,d=0;
head1=(struct node *)malloc(sizeof(struct node));
head1->next=NULL;
p1=head1;
head2=(struct node *)malloc(sizeof(struct node));
head2->next=NULL;
p2=head2;
p=head->next;
while(p)
{
if(p->data%2==0)
{
c++;
p1->next=p;
p1=p;
}
else
{
d++;
p2->next=p;
p2=p;
}
p=p->next;
}
printf("%d %d\n",c,d);
print(head1,c);
print(head2,d);
}
int main()
{
int n;
struct node *head;
scanf("%d",&n);
head=creat(n);
chai(head);
return 0;
}