#include#include#define MAXNUM 20struct stacktype{int stack[MAXNUM];int top;};void InitStack(struct stacktype *s){s->top=-1;}int StackEmpty(struct stacktype *s){return(s->top==0);}int push(struct stacktype *s,int x){ if(s->top >= MAXNUM-1)return false;elses->top++;s->stack[s->top]=x;return true;}int pop(struct stacktype *s){ if(s->top top--;return(s->stack[s->top+1]);}void dec_to_bin(int N,int B){int e;struct stacktype *s;\x05InitStack(s); //初始化堆栈,算法定
#include
#include
#define MAXNUM 20
struct stacktype
{
int stack[MAXNUM];
int top;
};
void InitStack(struct stacktype *s)
{s->top=-1;
}
int StackEmpty(struct stacktype *s)
{return(s->top==0);
}
int push(struct stacktype *s,int x)
{ if(s->top >= MAXNUM-1)
return false;
else
s->top++;
s->stack[s->top]=x;
return true;
}
int pop(struct stacktype *s)
{ if(s->top top--;
return(s->stack[s->top+1]);
}
void dec_to_bin(int N,int B)
{
int e;
struct stacktype *s;
\x05InitStack(s); //初始化堆栈,算法定义见课本
\x05while(N){
\x05\x05push(s,N%B);
\x05\x05N=N/B;
\x05}
\x05while(StackEmpty(s)){ //堆栈判空,算法定义见课本
\x05\x05e=pop(s);
\x05\x05printf("%d",e);
\x05}
}
void main()
{int a;
scanf("%d",&a);
dec_to_bin(a,2);
}
运行没有错误但就是出现local variable 's' used without having been initialized这个的错误