#include <stdio.h>
#include <malloc.h>
#include <stdlib.h>
#include <math.h>
#define initstack 100
#define Error 0
#define OK 1
#define FALSE-1
typedef int Status;
typedef int SElemType;
typedef struct {
SElemType *base;
SElemType *top;
int stacksize;
}Sqstack;
Status InitStack(Sqstack &S){
S.base = (SElemType *)malloc(initstack *sizeof(SElemType));
if(!S.base) return Error;
S.top=S.base;
S.stacksize=initstack;
return OK;
}
Status Pop(Sqstack &S,SElemType &e){
if(S.base == S.top)
return Error;
e = *(--S.top);
return OK;
}
Status Push(Sqstack &S,SElemType e){
*S.top++ = e;
return OK;
}
Status StackEmpty(Sqstack &S){
if(S.top == S.base){
return OK;
}
return Error;
}
int main(int argc, char** argv) {
SElemType e=0;
Sqstack S;
InitStack(S);
SElemType N;
scanf("%d",&N);
while(N){
Push(S,N%8);
N/=8;
}
while(!StackEmpty(S)){
Pop(S,e);
printf("%d",e);
}
return 0;
}
#include <malloc.h>
#include <stdlib.h>
#include <math.h>
#define initstack 100
#define Error 0
#define OK 1
#define FALSE-1
typedef int Status;
typedef int SElemType;
typedef struct {
SElemType *base;
SElemType *top;
int stacksize;
}Sqstack;
Status InitStack(Sqstack &S){
S.base = (SElemType *)malloc(initstack *sizeof(SElemType));
if(!S.base) return Error;
S.top=S.base;
S.stacksize=initstack;
return OK;
}
Status Pop(Sqstack &S,SElemType &e){
if(S.base == S.top)
return Error;
e = *(--S.top);
return OK;
}
Status Push(Sqstack &S,SElemType e){
*S.top++ = e;
return OK;
}
Status StackEmpty(Sqstack &S){
if(S.top == S.base){
return OK;
}
return Error;
}
int main(int argc, char** argv) {
SElemType e=0;
Sqstack S;
InitStack(S);
SElemType N;
scanf("%d",&N);
while(N){
Push(S,N%8);
N/=8;
}
while(!StackEmpty(S)){
Pop(S,e);
printf("%d",e);
}
return 0;
}