#include"iostream"
#include"stdio.h"
using namespace std;
string dui[8]={"000","001","010","011","100","101","110","111"};
int main()
{
char ai[100]; int a=125; string jj;
sprintf(ai,"%o",a);
for(int i=0;ai[i];i++) jj+=dui[ai[i]-'0'];
cout<<jj;
return 0;
}
思路:先将十进制转化为八进制并存储在字符串中,然后八进制以一位对三位转化为二进制