⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 2.2.c

📁 自己写的数据结构课程程序
💻 C
字号:
#include<stdio.h>
#define NULL 0
struct Node
{int data;
 struct Node *next;
};
struct Stack
{struct Node *base;
 struct Node *top;
 int stacksize;
};
struct Stack S;
void InitStack()
{S.base=NULL;
 S.top=NULL;
 S.stacksize=0;
}
void Push(int x)
{struct Node *p;
 p=(struct Node*)malloc(sizeof(struct Node));
 p->data=x;
 p->next=S.top;
 S.top=p;
 S.stacksize++;
}
int StackEmpty()
{if(S.top==NULL)
   return 1;
 else
   return 0;
}
void Pop(int *p)
{*p=S.top->data;
 S.top=S.top->next;
 S.stacksize--;
}
void conversion()
{int N,e;
 InitStack();
 scanf("%d",&N);
 while(N)
   {Push(N%2);
    N=N/2;
   }
 while(!StackEmpty())
   {Pop(&e);
    printf("%d",e);
   }
}
void main(void)
{conversion();
 getch();
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -