Run ID 作者 问题 语言 测评结果 Time Memory 代码长度 提交时间
69654 彭林江 十进制转二进制 C++ Accepted 1 MS 276 KB 314 2024-04-06 11:25:57

Tests(20/20):


Code:

#include<bits/stdc++.h> using namespace std; int main() { int n; cin >> n; if(n == 0){ cout << 0; return 0; } int a[32] = {0}; // 将数组全部清0 int cnt = 0; while(n != 0) { a[cnt++] = n % 2; n /= 2; } for(int i = cnt-1; i >= 0; i--) { cout << a[i]; } return 0; }