0
0
已采纳
递归主函数:(上面没有执行清0,请自己在主函数里修改)
string he2x;
string f(string he2x)
{
if(he2x.size()==1)
{
if(he2x=="0") return "0000";
if(he2x=="1") return "0001";
if(he2x=="2") return "0010";
if(he2x=="3") return "0011";
if(he2x=="4") return "0100";
if(he2x=="5") return "0101";
if(he2x=="6") return "0110";
if(he2x=="7") return "0111";
if(he2x=="8") return "1000";
if(he2x=="9") return "1001";
if(he2x=="A") return "1010";
if(he2x=="B") return "1011";
if(he2x=="C") return "1100";
if(he2x=="D") return "1101";
if(he2x=="E") return "1110";
if(he2x=="F") return "1111";
}
string tmp=he2x.substr(he2x.size()-1,1);
return f(he2x.substr(0,he2x.size()-1))+f(tmp);
}
0
