#include "iostream.h"
#include "new.h"
typedef struct dulieu
{
int data;
dulieu *tiep;
}so;
so *top,*p;
void push(int n)
{
p = (so*)new so;
p->data = n;
p->tiep = top;
top = p;
}
void pop(int &m)
{
p = top;
m = p->data;
top = top->tiep;
free(p);
}
void chuyen_co(int n, int c)
{
top = NULL;
while(c!= 0)
{
push(n%c);
n = n/c;
}
}
void hien(int n, int c)
{
cout<<"
So "<<n<<" sau khi chuyen co so "<<c<<" la :"<<endl;
while(top !=NULL)
{
int n;
pop(n);
if(n<10) cout<<n;
else
cout<<char(n+55);
}
}
int main()
{
int a,b;
cout<<"
Nhap gia tri : ";
cin>>a;
cout<<"
Nhap co so : ";
cin>>b;
chuyen_co(a,b);
hien(a,b);
}