forked from rathoresrikant/HacktoberFestContribute
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
44 lines (40 loc) · 714 Bytes
/
main.cpp
File metadata and controls
44 lines (40 loc) · 714 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#include <iostream>
using namespace std;
int main()
{
unsigned long long int a;
cin >>a;
bool b[128];
for(int i=0;i<128;i++)
b[i]=false;
int compt=0;
while(a!=0)
{
if((a&1)==1)
{
b[compt]=true;
}
a=a>>1;
compt++;
}
//if you dont want format
for(int i=0;i<compt;i++)
{
if(b[compt-i-1])
cout<<1;
else
cout<<0;
}
cout <<endl;
//with format
int format;
cin >>format;
for(int i=0;i<format;i++)
{
if(b[format-i-1])
cout<<1;
else
cout<<0;
}
return 0;
}