BASIC-2 01字串

  • 依次输出[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;
}
posted @ 2020-04-15 16:30  啥也不是*  阅读(122)  评论(0)    收藏  举报