#include<iostream>
#include<stack>
using namespace std;
int main()
{
unsigned number,
remainder;
stack<int>stackOfRemainder;
char response;
do
{
cout<<"Enter positive integer to convert:";
cin>>number;
while(number!=0)
{
remainder=number%2;
stackOfRemainder.push(remainder);
number/=2;
}
cout<<"Base-two representation: ";
while(!stackOfRemainder.empty() )
{
remainder=stackOfRemainder.top();
stackOfRemainder.pop();
cout<<remainder;
}
cout<<endl;
cout<<"\nMore (Y or N)? ";
cin>>response;
}
while(response=='Y'||response=='y');
}
以10为基转换为以2为基
最新推荐文章于 2021-12-06 13:21:42 发布