1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
#include "stack.h" int main(void) { Stack s; int number, ans; InitStack(&s); printf("Please enter a number: "); scanf("%d", &number); while (number) { Push(&s, number%2); number /= 2; } while (!StackIsEmpty(&s)) { printf("%d",GetTop(&s)); Pop(&s, &ans); } putchar('\n'); return 0; }