数据结构

include<stdio.h>

include<stdlib.h>

define initSize 20

typedef int SElemType;
typedef struct{
int elem;
int maxSize,top;
}SeqStack;
int main(){
SeqStack S;
int x,j,count;
S.elem= (SElemType
)malloc(initSize*sizeof(SElemType));//创建栈空间 ,chu shi hua
S.maxSize=initSize; //
S.top=-1;

if(S.top==S.maxSize-1) return 0;
S.elem[++S.top]=x;//指针先加1,再加栈
//shu ru
scanf("%d",x);
while(x){
x=x/2;
j=j%2;
S.elem[++S.top]=j;
count++;
printf("%d",count);
}
//chu zhan
j=S.elem[S.top--];
printf("%d",S.elem[S.top]);

}

posted @ 2019-04-25 17:13  赵薇薇  阅读(94)  评论(0编辑  收藏  举报