#define _CRT_SECURE_NO_WARNINGS
#define _CRT_SECURE_NO_DEPRECATE
#pragma warning(disable:4996);
#include<stdio.h>
#include <stdlib.h>
#define ok 1
#define error 0
#define overflow -2
#define stackmaxsize 100
typedef int selemtype;
typedef struct
{
selemtype* base;
selemtype* top;
int tacksize;
}stack;
char initstack(stack &s)
{
s.base = (selemtype*)malloc(stackmaxsize * sizeof(selemtype));
if (s.base)
exit(overflow);
s.base = s.top;
s.tacksize = stackmaxsize;
return ok;
}
char push(stack& s, selemtype e)
{
if (s.top - s.base >= s.tacksize)
return error;
*s.top = e;
s.top++;
return ok;
}
char pop(stack &s, selemtype e)
{
if (s.base == s.top)
return error;
e = *s.top;
s.top--;
}
void conversion(stack &s, int n)
{
int e;
if (n > 0)
{
while (n)
{
push(s, n %8);
n = n / 8;
}
}
while (s.top != s.base)
{
pop(s,n);
printf("%d", n);
}
}
int main()
{
int n;
stack s;
initstack(s);
scanf("%d", &n);
conversion(s, n);
}
#include<stdio.h>
#include<stdlib.h>
#define maxvector 150
struct stack
{
int data[maxvector];
int top;
};
void init(struct stack *L)
{
memset(L->data,0,sizeof(L->data));
L->top=0;
}
int pop(struct stack *L)
{
if(L->top<=0) return -1;
else return L->data[--L->top];
}
void push(struct stack *L,int num)
{
if(L->top<maxvector-1)
L->data[L->top++]=num;
else
printf("error");
}
int gettop(struct stack L)
{
if(L.top<=0) return -1;
else return L.data[L.top-1];
}
void conversion(int n)
{
struct stack L;
init(&L);
while(n>0)
{
push(&L,n%8);
n/=8;
}
while(L.top)
{
printf("%d",gettop(L));
pop(&L);
}
}
int main()
{
int n;
scanf("%d", &n);
conversion(n);
return 0;
}