Hi, could somebody help me how to write a function that sort elements in two dynamic stacks(contained in an external file) by the quicksort method?I think I have written the other functions correctly but I find hard time on this one.Please help me if you can, I will appreciate it very much :)
#include <iostream>
#include <stdlib.h>
#include <fstream>
using namespace std;
struct elem {
int key;
elem *next;
} *stack;
void push(stack& S, int n) {
stack p = S;
S = new elem;
S->key = n;
S->next = p;
}
int pop(stack& S) {
int n;
stack p = S;
n = S->key;
S = S->next;
delete p;
return n;
}
void file_input()
{
int a;
ifstream file_1;
file_1.open("file.txt", ios::in);
if (file_1)
{
while (!file_1.eof())
{
file_1 >> a;
push(s1, a);
}
file_1.close();
cout << endl << "Done" << endl << endl;
}
else
cout << "Error" << endl;
}