#include <iostream>
#include <string>
#include <stack>
using namespace std;
void conversion(int source,int base)
{
int i=0,j=0;
stack<int> s;
string number("");
while(source)
{
j = source%base;
source = source/base;
s.push(j);
}
while(!s.empty())
{
number.append(string(1,s.top()+'0'));
s.pop();
}
cout<<number<<endl;
}
void main()
{
conversion(1024,2);
#include <string>
#include <stack>
using namespace std;
void conversion(int source,int base)
{
int i=0,j=0;
stack<int> s;
string number("");
while(source)
{
j = source%base;
source = source/base;
s.push(j);
}
while(!s.empty())
{
number.append(string(1,s.top()+'0'));
s.pop();
}
cout<<number<<endl;
}
void main()
{
conversion(1024,2);
}
因为c++中的cout默认成绩