#include <iostream>
#include <math.h>
using namespace std;
int main (void)
{
long a,b;
while(cin>>a)
{
int array1[32];
int array2[32];
int d=0;
int e =0;
int f =0;
int g=0,h=0,l=1,k=0;
while(a>0)
{
if(a ==1){
array1[e]=1;
e++;
for(int i = e-1;i>=0;i--){
array2[f]=array1[i];
f++;
}
break;
}
else if((a%2)!=0){
a = a-1;
a = a/2;
array1[e]= 1;
e++;
}
else if((a%2)== 0){
a = a/2;
array1[e]=0;
e++;
}
}
for(int i =0;i<e;i++)
{
cout<<array2[i];
}
cout<<endl;
}
return 0;
}
#include
#include
using namespace std;
int main (void)
{
long a,b;
while(cin>>a)
{
int array1[32];
int array2[32];
int d=0;
int e =0;
int f =0;
int g=0,h=0,l=1,k=0;
while(a>0)
{
if(a ==1){
array1[e]=1;
e++;
for(int i = e-1;i>=0;i--){
array2[f]=array1[i];
f++;
}
break;
}
else if((a%2)!=0){
a = a-1;
a = a/2;
array1[e]= 1;
e++;
}
else if((a%2)== 0){
a = a/2;
array1[e]=0;
e++;
}
}
for(int i =0;i<e;i++)
{
cout<<array2[i];
}
cout<<endl;
}
return 0;
}
解題報告不是讓你貼答案。