Run ID:108086

提交时间:2025-01-19 14:24:25

#include<bits/stdc++.h> using namespace std; int y[32];//数组用来倒序 int cut = 0;//累加器 int main() { int n,yu; cin >> n; while(n != 0) {//除二取余,终止条件为商(n)等于0 yu = n% 2;//算出余数 y[cut] = yu;//装入数组 cut++; n = n / 2; } for(int i = cut-1; i >= 0; i++) { //倒序输出 cout << y[i]; } return 0; }