Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

面试题17的Increment(char* number)函数有点难读懂,感觉不需要那么复杂,自己写了个函数 #58

Open
lhphysics opened this issue Aug 10, 2019 · 0 comments

Comments

@lhphysics
Copy link

bool increment(char* number)
{
int len = strlen(number);
for (int index = len - 1; index >= 0; index--)
{
if ('9' == number[index])
{
if (0 == index)
{
return false;
}
number[index] = '0';
}
else
{
number[index] += 1;
break;
}
}
return true;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant