#include using namespace std; int main() { char arr[32] = ""; int len = 0; int n; cout << "请输入一个正整数: "; cin >> n; while (n) { arr[len++] = n % 2 + 48; //// 将数字0或1转成 字符'0'或'1'; 48是'0'的ASCII码值 n /= 2; } while (len) cout << arr[--len]; cout << endl; return 0; }