/*
#include <stdio.h>
#include <stdlib.h>
int main()
{
printf("Hello world!\n");
return 0;
}
*/
/*
#include <stdio.h>
#include "DlinkedList.h"
int whoisPrecede(int d1,int d2)
{
if(d1<d2){
return 0;
}
else{
return 1;
}
}
int main(void)
*/
#include <stdio.h>
#include <stdlib.h>
#include <malloc.h>
typedef struct _node
{
int data;
struct _node *next;
} Node;
int main(void)
{
Node *head=NULL;
Node *tail=NULL;
Node *cur=NULL;
Node *newNode=NULL;
Node *DummyNode=NULL;
int readData;
while(1)
{
scanf("%d", &readData);
if(readData<1)
{
break;
}
newNode=(Node*)malloc(sizeof(Node));
newNode->data=readData;
if(head==NULL)
{
head=newNode;
newNode->next = NULL;
tail=newNode;
}
else
{
cur=head;
while( cur->next!=NULL && cur->next->data<readData)
{
cur=cur->next;
}
newNode->next = cur->next;
cur->next = newNode;
}
printf("=======\n");
cur=head;
printf("%d ",cur->data);
while(cur->next!=NULL)
{
cur=cur->next;
printf("%d ",cur->data);
}
printf("\n=======\n");
}
/*
printf("\n");
if(head==NULL)
{
printf("---------------------------");
}
else
{
cur=head;
printf("%d ",cur->data);
while(cur->next!=NULL)
{
cur=cur->next;
printf("%d ",cur->data);
}
}
printf("\n");
if(head==NULL)
{
return 0;
}
else
{
Node* delNode=head;
Node*delNextNode=head->next;
printf("%d",head->data);
free(delNode);
while(delNextNode!=NULL)
{
delNode=delNextNode;
delNextNode=delNextNode->next;
printf("%d\n",delNode->data);
free(delNode);
}
}*/
return 0;
}