#include
using namespace std;
const int StackSize=50;
template
class SeqStack
{
public:
SeqStack(){top=-1;}//初始化栈空是栈顶指针为-1
~SeqStack(){}
void Push(DataType x);
DataType Pop();
int Empty(){top=-1?return 1:return 0;}
private:
DataType data[StackSize];
int top;
};
template
void SeqStack::Push(DataType x)
{
if(top==StackSize-1)throw"上溢";
data[top]=x;
++top;
}
template
DataType SeqStack::Pop()
{
if(top==-1)throw"下溢";
x=data[top];
--top;
return x;
}
class change
{
public: int* opertion();
};
template
class two:change
{
public:
int* opertion(int x)
{
int a[50];
SeqStack object;
int i=0;
while(x!=0)
{
object.Push(x%2)
x=x/2;
}
while(!object.Empty())
{
a[i]=object.pop();
}
return a;
}
};
template
int main()
{
int x=16;
two A;
A.opertion(x);
cout<<x;
}