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

12- 题目"输出从1到最大的N位数"第一种解法有问题 #16

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

12- 题目"输出从1到最大的N位数"第一种解法有问题 #16

WymanY opened this issue Aug 10, 2019 · 0 comments

Comments

@WymanY
Copy link

WymanY commented Aug 10, 2019

12.求1-N的所有的最大N为数的解法有问题,我刚开始使用swift翻译之后,发现结果不对,然后我把你的代码粘贴到编辑器里,使用C++写,发现是你本身的代码有问题。

代码见此

假设此时len = 2, "1,0",takeover = 1,走第一个方法内,nsum = 2,后面又有一个 nSum ++ ,导致sum变成3,高位变成30,直接越过了20-30的所有的数。

用你的代码的结果运行如下
运行结果

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