I am currently working on a code using Linked List. I would like my code to do the following:

1. User Enter integers between 1-60 (first List)
2. The application to check for all the repeated entries, remove them from the initial list and store them on a second list
3. Now that the first list has only one copy of each entry, the application should randomly select a node (using for loop multiple times). After the selection is made, the stored information on the node should be shown and that node to be deleted (but temporarily)
4. After the required number of (5) node data has been printed, all the temporarily deleted nodes to be reinstored.
5. Once thats done, the details of the second list to printed in a summary form i.e frequency of each integer entered.

below is my code.

#include <iostream>
#include <stdlib.h>
#include <string>
#include <fstream>

using namespace std;

struct NODE {
   NODE *pNext;
   NODE *pPrev;
   int nData;

//declare head and tail of list
//originally the list is empty
NODE *pHead=NULL, *pTail=NULL;

void AppendNode(NODE *pNode);
void InsertNode(NODE *pNode, NODE *pAfter);
void RemoveNode(NODE *pNode);
void DeleteAllNodes( );
void discard_line(ifstream &in);

int main()
    int i = 0;
    NODE * pNode;
    NODE * pNode1;

    //Add items to linked list
        pNode = new NODE;    //allocate
	                        // memory for each node and make
                            // pointer point to the
        cin >> i;                    //dynamically allocated memory
    	pNode->nData = i;  //put some data in the node
        AppendNode(pNode); //add node to list
    }while((i >= 1 )&&(i <= 60));


    for(int i = 0; i < = 3; i++){	

    	for(int j = 0; j < 5; j++)
          pNode1 = pNode1 % (pNode->nData);
	}  */
    // Now display each item in list
    for(pNode = pHead; pNode != NULL; pNode = pNode->pNext)

   // DeleteAllNodes();

    for(pNode = pHead; pNode != NULL; pNode = pNode->pNext)
        cout<<pNode->nData<< "\t";

    system ("pause");
    return 0;

//function Implementations

void AppendNode(NODE *pNode)
   if (pHead == NULL) {     //if list is empty
      pHead = pNode;        //make head point to pNode
      pNode->pPrev = NULL;
   else {
      pTail->pNext = pNode;  //make tail point to pNode
      pNode->pPrev = pTail;
   pTail = pNode;        //tail is now pNode
   pNode->pNext = NULL;  //pNode next now points to NULL

/* Inserts a node into the list after pAfter
void InsertNode(NODE *pNode, NODE *pAfter)
   pNode->pNext = pAfter->pNext; //make next of new node point to "next" node
   pNode->pPrev = pAfter;               //make prev of new node point the "after" node

   if (pAfter->pNext != NULL)       // if we are NOT inserting at the end
      pAfter->pNext->pPrev = pNode;    //make prev of  "next" node point to the new node
      pTail = pNode;                      //if we are inserting at the end, make new node the tail

   pAfter->pNext = pNode;   //make next of  "after" node point to new node
// Removes the specified node from the list
void RemoveNode(NODE *pNode)
   if (pNode->pPrev == NULL)  //if removing the head
       pHead = pNode->pNext;

      pNode->pPrev->pNext = pNode->pNext;  //if removing a middle node

   if (pNode->pNext == NULL)  //if removing the tail
      pTail = pNode->pPrev;
      pNode->pNext->pPrev = pNode->pPrev;

   delete pNode;  //*free the memory

//****** Deletes the entire list******
void DeleteAllNodes( )
   while (pHead != NULL)   //keep on removing until the 
                           //head points to NULL

void discard_line(ifstream &in)
    char c;

    while (c!='\n');