VS2019
#include<iostream>
using namespace std;
int main()
{
int n;
int a[33];
int i = 0;
scanf_s("%d", &n);
for (i;; i++)
{
a[i] = n % 2;// 7/2=3(3.5)向下取整
n = n / 2;
if (n == 0)
break;
}
for (i; i >= 0; i--)//逆序输出
{
printf("%d", a[i]);
}
}