#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;
	 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<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");
 }