Pages

Sunday, August 7, 2011

a034. 二進位制轉換


#include
using namespace std;
#include

int main()
{
string output;
int input;
while(cin>>input)
{
if (input==0)
cout<<"0";
while(input>0)
{
if(input%2==1)
output +="1";
else
output +="0";
input/=2;
}

for(int i=output.length()-1;i>=0;i--)
{
cout< }
cout< output.clear();
}

return 0;
}

No comments:

Post a Comment