首页 > 其他 > 详细

BASIC-2 01字串

时间:2020-04-15 16:49:56      阅读:61      评论:0      收藏:0      [点我收藏+]
  • 依次输出[1,31]的二进制
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<int,int> P;
const int N=1e6+9;
const double PI=acos(-1);
#define line ‘\n‘
#define gt getchar()
#define mid ((L+R)>>1)
int read(){int x=0,op=1;char c=gt;while(!isdigit(c)){if(c==‘-‘)op=-1;c=gt;}while(isdigit(c))x=x*10+c-48,c=gt;return x*op;}
string get(int x)
{
	string str="";
	while(x)str=char(x%2+‘0‘)+str,x/=2;
	while(str.length()<5)str=‘0‘+str;
	return str;
}
int main()
{
	for(int i=0;i<=31;++i)cout<<get(i)<<line;
	return 0;
}

BASIC-2 01字串

原文:https://www.cnblogs.com/ZeroOne-World/p/12706235.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!