土法煉鋼,用 bitwise operation 應該會快些。
A basic method is used here, though bitwise operations should be faster.

ZeroJudge Link (Zh)

#include <stdio.h>

main() {
  int num;
  int buf[100];
  int top;
  while (scanf("%d", &num) != EOF) {
    top = 0;
    do {
      buf[top++] = num % 2;
      num /= 2;
    } while (num != 0);
    for (; top > 0; top--) printf("%d", buf[top-1]);
    printf("\n");
  }
  return 0;
}