CodingInterviews icon indicating copy to clipboard operation
CodingInterviews copied to clipboard

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

Open WymanY opened this issue 6 years ago • 0 comments

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

代码见此

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

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

WymanY avatar Aug 10 '19 11:08 WymanY