hi everyone..
i need to ask 2 questions..
first..is the below code done using recursion or not?
second..how can i make the below code take input from a text file instead of generating random numbers and make the output go to a new text file?
#include <iostream>
using std::cin;
using std::cout;
using std::endl;
#include<cstdlib>
#include<ctime>
using namespace std;
class stack
{
private:
static const int MAX=10;
int st[MAX];
int top;
public:
stack():top(-1){}
void push(int v){st[++top]=v;}
int pop(){return st[top--];}
bool isempty(){return (top==-1);}
bool isfull(){return top==MAX-1;}
void print()
{
while(!isempty())
cout<<pop()<<endl;
}
void print_reverse()
{
int i=0;
while(i!=MAX)
cout<<st[i++]<<endl;
}
};
int main(int argc, char *argv[])
{
srand(time(0));
stack x;
while(!x.isfull())
x.push(rand()%1000+1);
x.print();
cout<<"--------\n";
x.print_reverse();
cin.get();
return 0;
}