主站
DreamJudge
院校信息
专业题库
模拟考试
机试真题
专业课程
讨论区
兑换中心
登录
注册
上岸
以下题解仅供学习参考使用。
抄袭、复制题解,以达到刷AC率/AC数量或其他目的的行为,在N诺是严格禁止的。
N诺非常重视学术诚信。此类行为将会导致您成为作弊者。具体细则请查看N诺社区规则。
我能走到对岸吗
2024年4月24日 00:40
二进制数 (C++ 位运算)题解:
P1380
回复 0
|
赞 1
|
浏览 66
#include <bits/stdc++.h> using namespace std; int x; string res; int main() { cin >> x; while(x) { res.push_back((x & 1) + '0'); x >>= 1; } reverse(res.begin(), res.end()); cout << res; return 0; }
FCC
2024年3月15日 20:38
二进制数 题解:十进制转二进制(除留余数法)+vector<int>反
P1380
回复 0
|
赞 0
|
浏览 210
#include <bits/stdc++.h> using namespace std; int main(){ unsigned int n; cin >> n; int x; vector<int> arr; //十进制转二进制(除留余数法) while( n > 0 ){ x = n % 2; //注意是对2取模,因为转换成二进制 n /= 2; //注意是除2,因为转换成二进制 arr.push_back( x ); //非栈结构,相当于数组,故输出时反向输出 }...
光明守护神
2024年3月14日 21:24
二进制数 题解:C++
P1380
回复 0
|
赞 0
|
浏览 150
#include <iostream> #include <vector> using namespace std; int main() { auto n = 100000000; while (cin >> n) { vector<int> r(0); ...
FIVEszc
2024年3月11日 23:38
二进制数 题解:C++
P1380
回复 0
|
赞 0
|
浏览 180
#include <bits/stdc++.h> using namespace std; int main() { int num[32]={0}; unsigned int a; int i=0; scanf("%d",&a); while(a>0){ int n=a%2; num[i]=n; i++; a/=2; } i--; for(;i>=0;i--) printf("%d",...
小酒
2024年3月11日 15:36
二进制数 题解:
P1380
回复 0
|
赞 0
|
浏览 211
1380解题思路 #include <bits/stdc++.h> using namespace std; int main() { int n,i=0; int a[105]={0}; scanf("%d",&n); while(n>0)  ...
小王桐学
2024年1月27日 15:33
二进制数 题解:递归解决
P1380
回复 1
|
赞 1
|
浏览 440
#include <stdio.h> int Binary(int n) { if(n >= 2) Binary(n/2); printf("%d",n%2); } int main() { int n; while(scanf("%d",&n) != EOF) { Binary(n); } return 0; }
fzh
2024年1月14日 11:05
二进制数 题解:C语言 两种方法 第一种itoa 第二种 栈
P1380
回复 0
|
赞 1
|
浏览 486
#include<stdio.h> #include<stdlib.h> //方法一 /* int main() { int n; while(scanf("%d",&n)!=EOF) { char result[9]; itoa(n,result,2); printf(&q...
928上岸梦校!
2023年8月5日 10:48
常规进制转换
P1380
回复 0
|
赞 2
|
浏览 665
使用STL容器vector存储二进制串 #include <bits/stdc++.h> using namespace std; int main() { int n; while (cin >> n) { vector<int> bin; while (n != 0) { int remainder = n % 2; bin.push_back(remainder); ...
Hegel
2023年3月18日 16:35
十进制转二进制
P1380
回复 0
|
赞 0
|
浏览 2.0k
#include <iostream> using namespace std; int main() { unsigned int a; while (cin >> a) { string res = ""; while (a > 0) { char t = a % 2 + '0'; res = t + res; a /= 2; } cout << res << endl; } return 0; }
落翼
2023年1月21日 15:20
python求解
P1380
回复 0
|
赞 0
|
浏览 3.0k
使用bin函数可轻松求解: while True: try: a = input() a = bin(int(a)) print(a[2:]) except: break
1
2
题目
二进制数
题解数量
14
发布题解
热门题解
1
常规进制转换
2
二进制数 题解:递归解决
3
c 二进制数
4
二进制数
5
二进制数
6
二进制数 (C++ 位运算)题解:
7
二进制数 题解:C语言 两种方法 第一种itoa 第二种 栈
8
二进制数 题解:C++
9
思路比较直
10
十进制转二进制