#include <iostream>
#include <cstdio>
using namespace std;

#define MAXSIZE 100

typedef int Status;
typedef int Elem;

typedef struct sqStack
{
int len;
Elem *base;
Elem *top;
}sqStack;

Status InitStack(sqStack &s)
{
s.base = new Elem[MAXSIZE];
if (!s.base) return -1;

s.top = s.base;
s.len = MAXSIZE;

return 1;
}

Status Push(sqStack &s, Elem e)
{
if (s.top - s.base == s.len) return -1;
else *s.top++ = e;

return 1;
}

Status Pop(sqStack &s, Elem &e)
{
if (s.top == s.base) return -1;
else e = *--s.top;

return 1;
}

Status GetTop(sqStack &s)
{
if (s.top != s.base)
return *(s.top - 1);

else return -1;
}

Status StackEmpty(sqStack &s)
{
if (s.top == s.base)
return 1;

else return 0;
}

Status conversion(sqStack &s, int n, int key) //书上代码根本不对劲 你不觉得吗? 改了一下
{
InitStack(s);

while (n)
{
Push(s, (n%key));
n /= key;
}

while (!(StackEmpty(s)))// StackEmpty 没有这个代码 自己补充 其实也很好想
{
Elem e;
Pop(s, e);
cout << e;
}

return 1;
}

int main()
{
sqStack s;

conversion(s, 10, 2);
}