文章

211

粉丝

0

获赞

902

访问

30.9k

头像
01序列 题解:
P1001 计算机考研机试入门题
发布于2026年3月18日 11:00
阅读数 40

#include<bits/stdc++.h>
using namespace std;

string tobinary(int x){
	if (x == 0) 
		return "0"; 
	string bin = ""; 
	while (x > 0) { 
		bin += (x & 1) ? '1' : '0';  
		x >>= 1; 
	}  
	reverse(bin.begin(), bin.end());
	return bin;
}	
int main(){
	for(int i=0;i<64;i++)
		cout << setw(6) << setfill('0') << tobinary(i) << endl;
	return 0;
}	

 

登录查看完整内容


登录后发布评论

暂无评论,来抢沙发