#include
#include
typedef struct sStack
{int data[100];
int top;
} seqstack;
void initialstack(seqstack &S)
{S.top=-1;
}
bool stackempty(seqstack &S)
{
}
bool pushstack(seqstack &S,int x)
{if(stackfull(S))
return false;
else {S.top++;
S.data[S.top]=x;
return true;
}
}
bool popstack(seqstack &S,int &x)
{if(stackempty(S))
return false;
else{x=data.[S.top];
S.top--;
return true;
}
}
void main()
{int n;
int x;
seqstack S;
initialstack(&S);
printf("请输入非负十进制数:");
scanf("%d",&n);
if(n==0) printf("对应八进制数为:/n0");
while(n!=0)
{if(S.top==100) printf("/n栈满结束");
else {x=n%2;
pushstack(S,x);
n=n/2;
}
}
if(S.top==-1) printf("/n栈空结束");
else while(S.top!=-1){popstack(seqstack S,x);
printf("%d",x);
S.top--;
}