#include<iostream>
using namespace std;
/*******establish struct***************/
struct student
{
int score;
struct student *next;
};
student *header;
/***********establish linklist********/
student *creat()
{
student *ps,*pend;
header=NULL;
ps=new student;
cin>>ps->score;
pend=ps;
while(ps->score!=0)
{
if(header==NULL)
header=ps;
else
pend->next=ps;
pend=ps;
ps=new student;
cin>>ps->score;
}
pend->next=NULL;
delete ps;
return header;
}
/*************showlist()*************/
void showlist(student *p)
{
while(p)
{
cout<<p->score<<endl;
p=p->next;
}
}
/***************insert noder*********/
void insert(student* pt)
{
if(header==NULL)
{
header=pt;
pt->next=NULL;
return;
}
if(header->score>pt->score)
{
pt->next=header;
header=pt;
return;
}
for(student* p=header;p->next;p=p->next)
{
if(p->next->score>pt->score)
{
pt->next=p->next;
p->next=pt;
return;
}
}
p->next=pt;
pt->next=NULL;
return;
}
/**********main()*******************/
int main()
{
header=creat();
struct student std;
cin>>std.score;std.next=NULL;
insert(&std);
showlist(header);
return 0;
}