#include <stdio.h>
#include <conio.h>
#include <string.h>
#include <stdlib.h>

struct elem{
	int num;
	elem *next;
	};
	elem *first, *cur, *tmp, *last;
	char snum[10];

 void main()
 {
	 int n,k,flag=0;
	 puts("Input integer value or ENTER");
  first=new elem;
   gets(snum);
  first->num=atoi(snum);
  first->next=NULL;
   last=first;
   while(gets(snum),strlen(snum)!=0)
   { cur=new elem;
     cur->num=atoi(snum);
	 cur->next=NULL;
    if(cur->num%2==0)
	{ cur->next=first;
	  first=cur;
	}
	else
	{last->next=cur;
	 last=cur;
	}
   }
  puts("inputed spisok first -> last");
  cur=first;
  while(cur!=NULL)
  {printf("%5d",cur->num);
  cur=cur->next;
  }
  printf("\n");
    cur=first;
        while((cur!=NULL)&&(flag==0))
          if(cur->num%5==0)
            {  tmp=cur;
                flag=1;
             }
            else
               cur=cur->next;
        if( flag==0) puts("Elemetnt not found");
        else
         { cur=new elem;
	       cur->num=777;
		   cur->next=tmp->next;
		   tmp->next=cur;
		   if(tmp==last)
			   last=cur;
		}

  puts("Spisok after include"); 
  cur=first;
  while(cur!=NULL)
  {printf("%5d",cur->num);
  cur=cur->next;
  }
  printf("\n");	   
          
     


 }