单选题

要实现将一个输入的十进制正整数转化为二进制表示,下面横线上应填入的代码为(    )。

#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;

}

A

cout << bin.top(); bin.pop();

B

bin.pop(); cout << bin.top();

C

cout << bin.back(); bin.pop();

D

cout << bin.front(); bin.pop();

赣ICP备20007335号-2