鱼C论坛

 找回密码
 立即注册
查看: 2827|回复: 1

10进制转二进制,老哥们帮看看怎么改,感谢

[复制链接]
发表于 2018-4-21 21:57:06 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能^_^

您需要 登录 才可以下载或查看,没有账号?立即注册

x
#include<stdio.h>
#include<stdlib.h>
#include<malloc.h>
#define STACKSIZE 100

#define MAXSIZE 100

typedef struct{
int data[STACKSIZE];
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[S->top]=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];
  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[S->top];
}

//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()
{
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复

使用道具 举报

发表于 2018-4-22 10:52:06 | 显示全部楼层
加一个 除二 取余 的功能
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2024-5-8 23:57

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表