#include <stdio.h>
#include <stdlib.h>
#define MAXS 8//
#define ADD
8//
typedef struct
{
int *base;
int *top;
int stacksize;
}Sqstack;
void InitStack( Sqstack &s)
{
s.base = (int *) malloc (MAXS*sizeof(int));
if( !s.base )
exit(0);
s.top = s.base;
s.stacksize = MAXS;
}
void Push( Sqstack &s, int temp )
{
if( s.top-s.base>=MAXS )
{
s.base =(int *) realloc (s.base, (MAXS+ADD)*sizeof(int));
if( !s.base )
exit(0);
s.top = s.base + s.stacksize;
s.stacksize += ADD;
}
*s.top++ = temp;
}
void Pop( Sqstack &s, int &temp )
{
if( s.top==s.base )
return;
temp = *--s.top;
}
int main()
{
Sqstack s;
InitStack(s);
int n;
int temp;
printf("input the number:");
scanf("%d", &n);
while( n )
{
temp= n%8;
Push( s, temp );
n = n/8;
}
while( s.base != s.top )
{
Pop( s, temp );
printf("%d",temp);
}
printf("\n");
return 0;
}