我看过的没有#define的啊,例如
#define maxsize 100
#include<stdio.h>
#include<windows.h>
#include<malloc.h>
typedef struct
{
int stack[maxsize];
int top;
}seqstack;
seqstack *initstack()
{
seqstack *s;
s=(seqstack*)malloc(sizeof(seqstack));
if(!s)
{
printf("空间不足");return NULL;
}
else
{
s->top=0;
return s;
}
}
seqstack *push(seqstack *s,int x)
{
if(s->top==maxsize)
{
printf("the stack is overflow!\n");
return NULL;
}
else
{
s->stack[s->top]=x;
s->top++;
return s;
}
}
int stackempty(seqstack *s)
{
if(s->top==0)
return 1;
else
return 0;
}
int pop(seqstack *s)
{
int y;
if(s->top==0)
{
printf("the stack is empty!\n");
return FALSE;
}
else
{
s->top--;
y=s->stack[s->top];
return y;
}
}
void conversion(int N,int r)
{
int x=N,y=r;
seqstack *s;
s=initstack();
while(N!=0)
{
push(s,N%r);
N=N/r;
}
printf("\n十进制数%d所对应的%d进制数是:",x,y);
while(!stackempty(s))
printf("%d",pop(s));
printf("\n");
}
void main()
{
int n,r;
printf("请输入任意一个十进制整数及其所需转换的二至九间的任一进制数:\n");
scanf("%d%d",&n,&r);
conversion(n,r);
}