题解 | 二进制数(bupt)
二进制数
https://www.nowcoder.com/practice/103dd589fed14457a673c613d8de3841
#include <iostream> #include <vector> using namespace std; int main() { int n; while (cin >> n) { vector<int> s; while(n!=0) { int num=n%2; s.push_back(num); n/=2; } for(int j=s.size()-1; j>=0; j--) { cout << s[j]; } cout << endl; } } // 64 位输出请用 printf("%lld")