该段程序将 n 不停地除以 2,并输出此时的商和余数,直到 n=0 为止。 long long n; cin >> n; while (n != 0) { cout << n / 2 << ' ' << n % 2 << '\n'; n /= 2; }