1 条题解
-
0
#include<bits/stdc++.h> using namespace std; int main(){ string s = ""; // 定义了一个空字符串 int n; // 要进行转换的十进制 int r=2; // 要进行转换的r进制 这里是2进制 cin >>n; //读取n的值 while(n){ s +=n%r+'0'; // 把int类型转换为了字符类型(string) n/=r;// n每次除以r,直到n为0 为止 } //反转字符串 s reverse(s.begin(),s.end()); cout <<s; //输出最终的结果 return 0; }
信息
- ID
- 4584
- 时间
- 1000ms
- 内存
- 256MiB
- 难度
- 7
- 标签
- 递交数
- 48
- 已通过
- 11
- 上传者
粤公网安备44195502000195号