typedef struct Node { struct Node * Next, * pre; int Data; } DSLink; void intiDSLink (DSLink * & L, int * A, int L) { // create the first node L = (DSLink *) the malloc ( the sizeof (DSLink )); L -> L-Next => pre = NULL; DSLink * S, * pre; // Create a node for ( int I = 0 ; I <L; I ++ ) { // first interpolation method s = (DSLink *) malloc (the sizeof (DSLink)); // allocate memory space S-> Data = A [I]; // Assignment S-> L = pre; // front pointer points to the node before the node s-> next = L- > Next; // the pointer to the node before the node L-> Next = S; // the junction } DSLink * = L-Next> Next, * = L-T> Next; // output the while ( ! Next = NULL) { COUT << next-> Data << " " ; Next = next-> Next; } // remove duplicate and destroy Next = L-> Next; pre=L; while(next!=NULL){ if(pre->data==next->data){ //删除相等元素 pre->next=next->next; next->next->pre=pre; cout<<"删除"<<next->data<<" "; //释放结点 free(next); next=pre->next; }else{ pre=next; next=next->next; } } //输出 DSLink *n=t; while(n!=NULL){ cout<<n->data<<" "; n=n->next; } }