Middle of Double Linked List

Hi, I want to find the middle node of a dubly linked list, I write this two functions but this not works correctly, the compilator stops the execution when I insert most of one values in the list. One function update the middle node and the other shows the middle node

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
  void ActMitad(bool mitad){
             if( cont == 0 ){
                  mit = NULL;
             }
             else{
             int remainder = cont%2;
             if(mitad){
                     if( remainder == 0 ){
                     mit = mit->prev;
            }
            }
            else{
                 if( remainder == 1 ){
                     mit = mit->next;
                     }
        }
             
             if( cont == 1 ){
                  mit = first;
             }
             
    }
}
		int avelider(){
    if( cont > 0 ) return mit->edad;
    else return -1;
}


Any help? Thanks
Topic archived. No new replies allowed.