Program help

Hi!I have a slight problem with this program and I will be glad if anyone can help me:

The elements of the stacks have to be sorted with the bubble sort.
Creates a dynamic structure deque,which contains the elements of the two stacks and finds the smallest number,higher than the average value of all elements in the deque.
Function that reades the elements of the 2 stacks and the deck.The problem is that the sort function and the built function,which I use to create the new deque and to find the smallest number,higher than the average value of the elements of the deque don`t work.
.Thanks in advance!

#include<iostream>
#include<fstream>
using namespace std;

fstream fp;
//Files to read

char t1[]="F1.txt";

char t2[]="F2.txt";

//Files for record

char tt1[]="FF.txt";

//Deque structure

struct dek {

int key;

dek *next;

} *left = NULL, *right=NULL;

//Initialising of the 2 stacks

struct elem{

int key;

elem *next;

} *start1=NULL,*start2=NULL,*p;

void add_1(int n) //Adding elements in the first stack

{

elem *p = start1;

start1 = new elem;

start1->key = n;

start1->next = p;

}

void add_2(int n) //Adding elements in the second stack

{

elem *p = start2;

start2 = new elem;

start2->key = n;

start2->next = p;
}

// Прехвърляне на 1 стек в 1 файл

elem* readFile1(elem *start1, char *t1)

{
elem e; //Local variable of a stack type
int br1; //Local variable,whichs finds the number of elements in the stack

fp.open("F1.txt",ios::binary,ios::app| ios::in|ios::out); //Opens the binary file for reading,recording and applying