第38708题 单选题
要实现将一个输入的十进制正整数转化为二进制表示,下面横线上应填入的代码为( )。
#include <iostream>
using namespace std;

stack<int> ten2bin(int n) {
    stack<int> st;
    int r, m;

    r = n % 2;
    m = n / 2;
    st.push(r);

    while (m != 1) {
        r = m % 2;
        st.push(r);
        m = m / 2;
    }
    st.push(m);
    return st;
}

int main() {
    int n;
    cin >> n;
    stack<int> bin;
    bin = ten2bin(n);
    while (!bin.empty()) {
        _____________________ // 在此处填入代码
    }
    return 0;
}
{{ option.label }}
子题{{ index + 1 }} {{ child.type_label }}
{{ option.label }}
✓ 正确 ◐ 部分正确 ✗ 错误
程序运行统计
暂无判题统计
知识点:
提交{{ questionInfo.stats ? questionInfo.stats.submit_count : 0 }}次 正确率{{ statsAccuracy }}%
答案解析