int foo(int n)
{
if (n < 1){
return 0;
}
int result = 0;
for(int i = 1, factor = 1; i <= n; (factor += (pow(10.0, i))), ++i){
result += (i * factor);
}
return result;
}
int foo(int n)
{
if (n < 1){
return 0;
}
int result = 0;
for(int i = 1, factor = 1; i <= n; (factor += (pow(10.0, i))), ++i){
result += (i * factor);
}
return result;
}
转载于:https://www.cnblogs.com/wuOverflow/p/4921476.html