题解 | #二进制数#
二进制数
https://www.nowcoder.com/practice/103dd589fed14457a673c613d8de3841
#include <iostream> #include <string> #include <vector> #include <algorithm> #include <stack> #include <map> using namespace std; int main() { stack<int> mystack; int n; while (scanf("%d", &n) != EOF) { while (n != 0) { int t = n % 2; mystack.push(t); n /= 2; } while (!mystack.empty()) { int t = mystack.top(); printf("%d", t); mystack.pop(); } printf("\n"); } } // 64 位输出请用 printf("%lld")