Run ID | 作者 | 问题 | 语言 | 测评结果 | Time | Memory | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|
108067 | 刘慕莀 | 十进制转二进制 | C++ | Wrong Answer | 0 MS | 268 KB | 580 | 2025-01-19 14:19:49 |
#include <iostream> using namespace std; int main() { int a; cin >> a; if (a == 0) { cout << 0; return 0; } // Use a stack-like approach with division and modulus int b = 0; int c = 1; while (a > 0) { int d = a % 2; b = b + d * c; c *= 10; a = a / 2; } // Reverse the digits of b to get the correct binary representation int e = 0; while (b > 0) { e = e * 10 + b % 10; b /= 10; } cout << e << endl; return 0; }
------Input------
972586684
------Answer-----
111001111110000111111010111100
------Your output-----
0