#include class node {public: long a; node *next; }; main() {node *head,*p,*s; s=new node; cin>>s->a; head=NULL; while (s->a) {if (head==NULL) head=s; else p->next=s; p=s; s=new node; cin>>s->a; } p->next=NULL; p=head; delete s; node *q,*h,*j,*r,*i; h=new node;s=new node; s->next = p; while (s->next!=NULL) { j = s; q = s->next; while (q->next!=NULL) { if (q->next->anext->a) { j = q; } q = q->next; } if (j != s) { i= j->next; j->next = i->next; i->next = s->next; s->next = i; } s = s->next; } p = h->next; p=head; while (p) {coutnext; } delete s,h; }