#include
#define MAXSIZE 256
int Stack[MAXSIZE];
int top = -1;
bool isempty(){
return top == -1;
}
void push(int d){
Stack[++top] = d;
}
int pop(){
return Stack[top--];
}
char dec2hex(int x){
return (x>9?'a':'0') + (x%10);
}
int main(){
int x;
scanf("%d", &x);
//除16取余
while(x){
push(x%16);
x /= 16;
}
while(!isempty())
putchar(dec2hex(pop()));
}
等一下,我写一下