10进制转二进制,老哥们帮看看怎么改,感谢
#include<stdio.h>#include<stdlib.h>
#include<malloc.h>
#define STACKSIZE 100
#define MAXSIZE 100
typedef struct{
int data;
int top;
}SeqStack,*PSeqStack;
//1.初始化栈
PSeqStack Init_SeqStack(){
PSeqStack S;
S=(PSeqStack)malloc(sizeof(SeqStack));
if(S!=NULL)
S->top=-1;
return S;
}
//2.判断栈空
int Empty_SeqStack(PSeqStack S)
{
if(S->top==-1)
return 1;
else return 0;
}
//3.x进栈
int Push_SeqStack(PSeqStack S,int x)
{
if(S->top==STACKSIZE-1)
return 0;
else{
S->top++;
S->data=x;
return 1;
}
}
//4.出栈--栈顶元素赋给x
int Pop_SeqStack(PSeqStack S,int *x)
{
if(Empty_SeqStack(S)==1)
return 0;
else{
*x=S->data;
S->top--;
return 1;
}
}
//5.取栈顶元素返回
int GetTop_SeqStack(PSeqStack S)
{
if(Empty_SeqStack(S)==1){
printf("Empty Stack!\n");
return -1;
}
else
return S->data;
}
//6.销毁栈
int Destory_SeqStack(PSeqStack *S)
{
if(*S){
free(*S);
*S=NULL;
return 1;
}
return 0;
}
/*int main()
{
PSeqStack s;
int x=0;
s=Init_SeqStack();
Push_SeqStack(s,1);
Push_SeqStack(s,2);
Push_SeqStack(s,3);
Push_SeqStack(s,4);
printf("Top:%d ",GetTop_SeqStack(s));
Destory_SeqStack(&s);
return 1;
}*/
int main()
{
加一个 除二 取余 的功能
页:
[1]