Help for a course work

Hi!I have a slight problem with this program and I will be glad if anyone can help me:
Create a program,which contains these functions:
Two stacks with int data,which are included in an outer file;
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.
The last function has to record the outstream rezults in an outer file.
Main function main() with a menu to choose functions and a check for the condition of the data.Thanks in advance!
This is the code,I`ve made so far:

#include <iostream>
using namespace std;

struct elem
{
int key;
elem *next;

} *P,*N;

void push(int n, elem *&start)
{
elem *p = start;
start = new elem;
start -> key=n;
start -> next=p;
}

int pop(int &n, elem *&start)
{
if(start)
{
elem *p=start;
n=start->key;
start=start->next;
delete p;
return 1;
}
else return 0;
}
void bubbleSort2(elem *N[], int& n)
{ int i=1, j, k;
for (i=0; i<n-1; i++)
for (j=n-1; j>=i; j--)
if (P[j].key > P[j+1].key) {
k=(int) N[j]; N[j]=N[j-1]; k=(int) N[j-1];
k = j;
}



}
void bubbleSort3(elem *P [], int &n)
{ int i=1, j, k;
for (i=n; i<n-1; i++)
for (j=n-1; j>=i; j--)
if (N[j].key > N[j+1].key) {
k=(int) P[j]; P[j]=P[j-1]; k=(int)P[j-1];
k = j;
}

}

void main()
{
int n=1;
while(n)
{
cout<<"\n Vuvedi cifra: "<<endl;
cin>>n;

if(n>0)
{ push(n,P);

}
else
{
if(n<0)
push(n,N);

}
}
while(pop(n,P))

cout<<" "<<n<<"\t";
cout<<"Sortirane1"<<endl;
bubbleSort2( &N,n);
while(pop(n,N))

cout<<" "<<n<<"\t";
cout<<"Sortirane2"<<endl;
bubbleSort3(&P,n);
cout<<endl;
}
The problem here is that your push() and pop() functions are creating a linked list, but your bubbleSort() functions assume that you have an array. Look at vector<> and try to rework the code using it instead of a linked list.

Good luck,
Dave
Thank you!I now realise my mistakes and I`ll write the full code tomorrow and I think it will be all right.
Topic archived. No new replies allowed.