题解 | #二进制数#
二进制数
https://www.nowcoder.com/practice/103dd589fed14457a673c613d8de3841
#include<iostream> #include<stack> using namespace std; int main() { int n; while (scanf("%d", &n) != EOF) { stack<int> binary; while (n != 0) { binary.push(n % 2); n /= 2; } while (!binary.empty()) { printf("%d", binary.top()); binary.pop(); } printf("\n"); } }