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

#include<conio.h>
struct elem {
int num;
   elem * next;
};
int main()
{ elem * first, *last,*p,*q,*n;
char s[80];
char sl[10];
int j,m;int fl;
size_t i;
 puts("Input string with number");
 gets(s);
 first=NULL;// списокпуст
 sl[0]='\0';
 j=0;
for(i=0;i<=strlen(s);i++)
if((s[i]==' ')||(s[i]=='\0'))
   { sl[j]='\0';
     m=atoi(sl);
     j=0;
     sl[0]='\0';
if (first==NULL)
     { first=new elem;
       first->num=m;
       first->next=NULL;
       last=first;
      }
else
      {  n=new elem;
         n->num=m;
    if(n->num<first->num)
    {n->next=first;
    first=n;
         }
    else
         {  fl=0;
            p=first;
            q=first;
        while((q=q->next)!=NULL&&!fl)
            {
            if(n->num<q->num)
              {n->next=p->next;
               p->next=n;
               fl=1;
              }
            else p=q;
           }
        if(!fl)
          {n->next=NULL;
        p->next=n;
        last=n;
          }
         }
      }
    }
else
    { sl[j]=s[i];
    j++;
    }


    printf("Spisok\n");
    q=first;
    while(q!=NULL)
    {printf("%6d",q->num);
     q=q->next;
    }
    printf("\n");
    getch();
    return 0;
}
