1 进制转换
1.1 利用栈的特点,将用户输入的十进制数转换为二进制数。
#include<stdio.h>
#include<stdlib.h>
#include<malloc.h>
#define M 100
typedef int datatype;
typedef struct{
datatype data[M];
int top;
}seqstack;
void InitStack(seqstack *s){
s->top=-1;
}
int StackEmpty(seqstack *s){
if (s->top>=0) return 1;
else return 0;
}
seqstack *push(seqstack *s,datatype x){
if (s->top==M-1) return NULL;
else
{
s->top++;
s->data[s->top]=x;
}
return s;
}
datatype pop(seqstack *s){
datatype x;
x=s->data[s->top];
s->top--;
return x;
}
void main(){
seqstack *s;
datatype n,e;
int i=0,j=0;
scanf(&#