#include<iostream>
using namespace std;

#define
#define
#define

typedef int Status;
typedef int SElemType;

typedef struct StackNode {
SElemType data;
struct StackNode* next;
}StackNode, * LinkStack;

// 链栈初始化
void InitStack(LinkStack& S) {
S = NULL;
}

// 判断链栈是否为空
Status StackEmpty(LinkStack S) {
if (S == NULL) return 1;
else return 0;
}

// 入栈
Status Push(LinkStack& S, SElemType e) {
LinkStack p;
p = new StackNode;
if (!p) exit(OVERFLOW);
p->data = e;
p->next = S;
S = p;
return OK;
}

// 出栈
Status Pop(LinkStack& S, SElemType& e) {
if (StackEmpty(S)) return ERROR;
LinkStack p;
e = S->data;
p = S;
S = S->next;
delete p;
p = NULL;
return OK;
}

/*---------------进制转换---------------*/
void Invert(LinkStack &S, int n) {
SElemType e;
int m;
cout << "请输入要转换的进制: ";
cin >> m;
while (n) {
Push(S, n % m);
n = n / m;
}

cout << "转换后的数字为: ";
while (!StackEmpty(S)) {
Pop(S, e);
cout << e;
}
cout << endl;
}

int main()
{
int n;
LinkStack S;
InitStack(S);
cout << "请输入要转换的数字: ";
cin >> n;
Invert(S, n);
return 0;
}
请输入要转换的数字: 1024
请输入要转换的进制: 2
转换后的数字为: 10000000000