Tonights problem is this:
Main function MUST look like this:
void main()
{ int input;
getinput(input);
print_stack(n);
print_recursion(n);
print_binary(n);
}
I'm trying to implement a class of STACK, and have three different outputs : stack, recursion, and no stack nor recursion.
Here is example of running program:
Please insert a number for binary representation:
10
The binary representation of 10 is (using stack): 1010
The binary representation of 10 is (using recursion): 1010
The binary representation of 10 is (no stack nor recursion): 1010
This is what I have so far:
#include<iostream>
using std::cout;
using std::cin;
using std::endl;
using std::istream;
using std:stream;
class STACK{
int data[100];
int top;
int n;
public:
void getinput();
void push(int target) {data[top++] = target;};
int isEmpty(){return !top;};
int pop() {return data[--top];};
};
int print_stack(int n)
{
if (n == 0)
return n;
cout << "The binary representation of 10 is (using stack): " << n.pop() << endl;
}
STACK getinput(int input)
{ int n;
cout << "Please enter a number for binary representation: \n";
cin >> n;
}
Ok, I'll admit, I'm out of my league here. I'm not sure where to go. I know I have big problems with the above. Please help!!