#include
struct node
{
int num;
struct node *next;
};
int isPrim(int n)
{
int i;
if(n==1)
return 0;
for(i=2;i*i<=n;i++)
if(n%i==0)
return 0;
return 1;
}
int main(void)
{
struct node *head, *t, *p;
int i;
head = t = NULL;
for(i=0;i<10;i++)
{
p = malloc(sizeof(struct node));
scanf("%d", &(p->num));
p->next = NULL;
if(head == NULL)
head = p;
else
t->next = p;
t = p;
}
for(p = head, t = NULL; p; t = p, p = p->next)
{
if(isPrim(p->num))
{
if(p == head)
head = p->next;
else
t->next = p->next;
free(p);
if(t == NULL)
p = head;
else
p = t;
}
}
for(p = head; p; p = p->next)
printf("%d ", p->num);
while(head)
{
p = head->next;
free(head);
head = p;
}
return 0;
}