标签:
C++ 吧里看到有人求助, 说是想写点代码求一个整数的位数, 以下是我的解决方法:
int32_t RecursionIter (const int64_t& num, const int32_t& result)
{
if (num < 0) {
return RecursionIter (-num, result);
}
else if (num / 10 == 0) {
return result;
}
else {
return RecursionIter (num / 10, (result + 1));
}
}
int32_t Recursion (const int64_t& num)
{
return RecursionIter (num, 1);
}
标签:
原文地址:http://www.cnblogs.com/wuOverflow/p/4298328.html