Example:
Input:
1->2->6->3->4->5->6, val = 6
Output: 1->2->3->4->5

//
//  DulList.hpp
//  DulList
//
//  Created by XQ on 2017/3/29.
//  Copyright © 2017年 XQ. All rights reserved.
//

#define valuetype int
#include <stdio.h>
#include <iostream>
#include <mm_malloc.h>

using namespace std;


typedef struct DulNode{
    valuetype data;
    struct DulNode *prior,*next;
}Node, *pDulNode;


class DulList{
public:
    pDulNode create_DulList();//create
    bool traverse_DulList(pDulNode L);//traverse
    bool insert_DulList(pDulNode &L,int i,valuetype e);//insert
    bool delete_DulList_i(pDulNode &L,int i);//delete i
    bool delete_DulList_e(pDulNode &L,valuetype e);//delete e
    bool replace_DulList_j(pDulNode &L,int i,valuetype e);//replace j
    bool replace_DulList_e(pDulNode &L,valuetype e1,valuetype e2);//replace e
    int search_DulList(pDulNode &L,valuetype e);//search
    bool sort_DulList(pDulNode &L);//sort
private:
    int length;
    pDulNode head;
    pDulNode tail;
};
//
//  DulList.cpp
//  DulList
//
//  Created by XQ on 2017/3/29.
//  Copyright © 2017年 XQ. All rights reserved.
//

#include "DulList.hpp"


pDulNode DulList::create_DulList(){
    int len;
    valuetype buf;
    cout << "Please input the list's length." << endl;
    cin >> len;
    length = len;
    head = (pDulNode)malloc(sizeof(DulNode));
    head->prior = NULL;
    head->next = NULL;
    head->data = len;
    pDulNode s = head;
    if(!head){exit(-1);}
    cout << "Please input " << length << " number." << endl;
    for(int count = 0 ; count < len ; count ++){
        cin >> buf;
        pDulNode p = (pDulNode)malloc(sizeof(DulNode));
        s->next = p;
        p->prior = s;
        p->next = NULL;
        p->data = buf;
        s = s->next;
        tail = p;
    }

    return head;
}//

bool DulList::traverse_DulList(pDulNode L){
    pDulNode p = L;
    while(p->next){
        p = p->next;
        cout << p->data << " ";
    }
    cout << endl;
    return true;
}//

bool DulList::insert_DulList(pDulNode &L, int i, int e){
    pDulNode p = L;
    if(i > length){cout << "i is too high." << endl;return false;}
    if(p->next){
        for(int count = 0 ; count < i ; count ++){
            p = p->next;
        }
        if(p->next){
            pDulNode s = (pDulNode)malloc(sizeof(DulNode));
            s->data = e;
            p->next->prior = s;
            s->prior = p;
            s->next = p->next;
            p->next = s;
            length ++;
        }
        else{
            pDulNode s = (pDulNode)malloc(sizeof(DulNode));
            s->next = NULL;
            s->data = e;
            s->prior = p;
            p->next = s;
            length ++;
        }
    }

    return true;
}//


bool DulList::delete_DulList_i(pDulNode &L, int i){
    pDulNode p = L;
    if(i > length){cout << "i is too high." << endl;return false;}
    if(p->next){
        for(int count = 0 ; count < i ; count ++){
            p = p->next;
        }
        pDulNode s = p->next;
        if(s){s->prior = p->prior;}
        p->prior->next = s;
        free(p);
        length --;
    }
    return true;
}//

bool DulList::delete_DulList_e(pDulNode &L, int e){
    pDulNode p = L;
    while(p->next){
            p = p->next;
            if(p->data == e){
                pDulNode s = p->next;
                if(s){s->prior = p->prior;}
                p->prior->next = s;
                free(p);
                length --;
            }
    }
    return true;
}//

bool DulList::replace_DulList_j(pDulNode &L, int j,int e){
    pDulNode p = L;
    if(j > length){cout << "j is too high." << endl;return false;}
    if(p->next){
        for(int count = 0 ; count < j ; count ++){
            p = p->next;
        }
        p->data = e;
    }
    return true;
}//

bool DulList::replace_DulList_e(pDulNode &L, int e1, int e2){
    pDulNode p = L;
    while(p->next){
        p = p->next;
        if(p->data == e1){
            p->data = e2;
        }
    }
    return true;
}//

int DulList::search_DulList(pDulNode &L, int e){
    int count = 0;
    int i = 0;
    pDulNode p = L;
    while(p->next){
        p = p->next;
        i ++;
        if(p->data == e){
            count ++;
            if(count == 1){cout << i << endl;}
        }

    }
    return count;
}//

bool DulList::sort_DulList(pDulNode &L){
    pDulNode p = L->next;
    int count = 0;
    while(p){
        pDulNode s = p->next;
        count ++;
        while(s){
            if(s->data < p->data){
              swap(s->data, p->data);
            }
            s = s->next;
        }

        p = p->next;
    }
    return true;
}
//
//  main.cpp
//  DulList
//
//  Created by XQ on 2017/3/29.
//  Copyright © 2017年 XQ. All rights reserved.
//

#include "DulList.hpp"
int main(){
    DulList DL;
    while(EOF){
        cout << "//*********START*********//" << endl;
        //create list
        pDulNode DL_Head = DL.create_DulList();
        cout << "The list's number is." << endl;
        DL.traverse_DulList(DL_Head);

        /*
        //delete i
        cout << "Select i to delete." << endl;
        int i;
        cin >> i;
        DL.delete_DulList_i(DL_Head,i);
        cout << "The list's number is." << endl;
        DL.traverse_DulList(DL_Head);
       */
        //delete e
        cout << "Select number to delete." << endl;
        int value;
        cin >> value;
        DL.delete_DulList_e(DL_Head,value);
        cout << "The list's number is." << endl;
        DL.traverse_DulList(DL_Head);
        /*
        //insert
        cout << "Select k to insert." << endl;
        int k;
        cin >> k;
        cout << "Select number to insert." << endl;
        int e_insert;
        cin >> e_insert;
        DL.insert_DulList(DL_Head,k,e_insert);
        cout << "The list's number is." << endl;
        DL.traverse_DulList(DL_Head);

        //repalce j
        cout << "Select j to replace." << endl;
        int j;
        cin >> j;
        cout << "Select number to replace." << endl;
        int e_replace;
        cin >> e_replace;
        DL.replace_DulList_j(DL_Head, j, e_replace);
        cout << "The list's number is." << endl;
        DL.traverse_DulList(DL_Head);

        //repalce e
        cout << "Select e1 to replace." << endl;
        int e1;
        cin >> e1;
        cout << "use e2 to replace e1." << endl;
        int e2;
        cin >> e2;
        DL.replace_DulList_e(DL_Head, e1, e2);
        cout << "The list's number is." << endl;
        DL.traverse_DulList(DL_Head);

        //search e
        cout << "Select e to search." << endl;
        int e_search;
        cin >> e_search;
        int count = DL.search_DulList(DL_Head, e_search);
        cout << "The number "<< e_search << " contain " << count << "." << endl;
        cout << "Sorting..." << "List is sorted." << endl;
        DL.sort_DulList(DL_Head);
        DL.traverse_DulList(DL_Head);
         */
        cout << "//*********END*********//" << endl;
    }
    return 0;
}