#include <iostream>

using namespace std;

struct Node
{
        int data;
        Node *next;
};

Node *createList (Node *head)
{
        struct Node *p, *s;
        int ch;
        cout << "Input a number,then press Enter. press Ctrl + Z to end input:" <<endl;
        while ((cin >> ch) && ch != EOF)
        {
                s = new Node;
                s->data = ch;
                if (head == NULL)
                {
                        head = s;
                        p = s;
                }
                else
                        p->next = s;
                s -> next = NULL;
                p = s;
        }
        return head;
}

void showList (Node *head)
{
        do
        {
                cout << head->data << '\n';    
                head = head->next;
        }while (head != NULL);
}

int main()
{
        Node *head1 = NULL, *head2 = NULL;
        
        head2 = createList(head1);    
        showList(head2);
        return 0;
}