C语言进制转换的程度解释

[复制链接]
查看11 | 回复0 | 2011-3-7 03:00:41 | 显示全部楼层 |阅读模式
#includestdio.h
#includeconio.h
#includemalloc.h
#define MaxSize 100
#define NULL 0

typedef struct
{
int data[MaxSize];
int top;
}SeqStack;

SeqStack *InitStack(void)
/*初始化栈*/
{
SeqStack *s;
s=(SeqStack *)malloc(sizeof(SeqStack));
if(!s)
{
printf(\"空间不足!\");
return 0;
}
else
{
s-top=-1;
return s;
}
}

int IsEmpty(SeqStack *s)
/*判断栈是否为空*/
{
if(s-top==-1) return 1;
else return 0;
}

int IsFull(SeqStack *s)
/*判断栈是否为满*/
{
return(s-top==MaxSize-1);
}

void Push(SeqStack *s,int n,int r)
/*入栈*/
{
while(n!=0)
{
if(!IsFull(s))
{
s-top;
s-data[s-top]=n%r;
n=n/r;
}
else
{
printf(\"栈满\");
return;
}
}
}

void Pop(SeqStack *s)
/*出栈*/
{
while(!IsEmpty(s))
{
if(s-top!=-1)
{
if(s-data[s-top]10) printf(\"%d\",s-data[s-top]);
else printf(\"%c\",\'A\' s-data[s-top]-10);
s-top--;
}
else
{
printf(\"栈空\");
return;
}
}
}

int main(int argc,char *argv[])
{
int n,r;
SeqStack *s;
s=InitStack();
printf(\"n,r:\");
scanf(\"%d,%d\",
Push(s,n,r),Pop(s);
getch();
return 0;
}
这个程序看不懂,谁能帮我解释拷贝
回复

使用道具 举报

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

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行