#include <stdio.h> #include <stdlib.h> #include <string.h> void binary_num(int, int); int main( int argc, char* argv[] ) { int a = 30; binary_num(a, sizeof(a) * 8); printf("\n"); system("pause"); return 0; } void binary_num(int a, int i) { if (i > 1) binary_num(a >> 1, --i ); if (a & 1) printf("1"); else printf("0"); }
时间: 2024-10-14 22:02:06