#include <stdio.h>
#include <string.h>
#include <stdlib.h>
struct spis
{char data[20];
  struct spis *v1; 
  struct spis *v2; 
  
};
void create(void); //создание списка
void list(spis *); //просмотр списка
void add(void);  //добавление списка
struct spis *head,*tail; 
int main()
{
	int nom;
    create();
    add();
    printf("list head:\n");
   	list(head);
   	printf("list tail:\n");
    list(tail);
    printf("the end\n");
    return 0;
}

void create(void)
{spis *p,*pred;
  pred=NULL;
  p=(spis *)malloc(sizeof(spis));
    /*printf(":Данные ");*/ gets(p->data);
      p->v1=pred;
    if (pred != NULL)
      pred->v2=p;
    else
      head=p;
    pred=p;
  tail=p;
  tail->v2=NULL;
}
void add(void) 
{
            spis *p,*pn; 
            //clrscr();
            pn=(spis *)malloc(sizeof(spis));
            //printf("Введите данные: ");
            gets(pn->data);            
            p=tail; 
            pn->v1=tail; 
            pn->v2=NULL;
            p->v2=pn;
            tail=pn; 
}

void list(spis *p)
{if (p==head)
  while (p != NULL)
    {puts(p->data);
      p=p->v2;
    }
   else if (p==tail)
  while ( p!= NULL)
  {
        printf("%s\n",p->data);
    p=p->v1;
  }
  else
    puts("Неверный адрес ");
}
