📄 shuzhizhuanhuan.txt
字号:
#define STACK_INIT_SIZE 100
#define STACKINCREMENT 10
typedef struct{
int *base;
int *top;
int stacksize;
}SqStack;
InitStack(SqStack *s)
{s->base=(int*)malloc(STACK_INIT_SIZE*sizeof(SqStack));
if(!s->base) printf("error");
s->top=s->base;
s->stacksize=STACK_INIT_SIZE;
}
void Push(SqStack *s,int e)
{
if(s->top-s->base>=s->stacksize)
{s->base=(int*)realloc(s->base,(s->stacksize+STACKINCREMENT)*sizeof(SqStack));
if(s->base) printf("error");
s->top=s->base+s->stacksize;
s->stacksize+=STACKINCREMENT;
}
*s->top++=e;
/*s->top++;*/
}
Pop(SqStack*s,int e)
{if(s->top==s->base)
printf("error");
else
{e=*--s->top;
return e;}
}
int StackEmpty(SqStack *s)
{if(s->top==s->base)
return 1;
else return(0);
}
main()
{int n;
SqStack s;
int e;
InitStack(&s);
scanf("%d",&n);
while(n)
{Push(&s,n%8);
n=n/8;
}
while(!StackEmpty(&s))
{
printf("%d",Pop(&s,e));
}
getch();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -