日期:2014-01-15  浏览次数:20360 次


/*           Name :    Fun_WheIncluded           Function :   判断选定的数字能否在给定的整数中           可以知道任何一个自然数都可以拆分成若干个2的幂的和,如:                1 = 2^0                2 = 2^1                3 = 2^0 + 2^1                4 = 2^2                5 = 2^0 + 2^2                6 = 2^1 + 2^4                7 = 2^0 + 2^1 + 2^2                8 = 2^3                9 = 2^0 + 2^3                10 = 2^1 + 2^3                11 = 2^0 + 2^1 + 2^3                12 = 2^2 + 2^3                13 = 2^0 + 2^2 + 2^3                14 = 2^1 + 2^2 + 2^3                15 = 2^0 + 2^1 + 2^2 + 2^3                16 = 2^4                17 = 2^0 + 2^4         将任意一个数解析为2的幂的和的方法——递归    规律:                如给定 14                  ∵ 2^3 < 14 < 2^4                  ∴ 14中必有8——2^3                  14 - 8 = 6                  ∵ 2^2 < 6 < 2^3                  ∴ 6中必有4——2^2                  6 - 4 = 2                         ∵ 2 = 2                  ∴ 14 = 2^3 + 2^2 + 2^1

            Parameters :  @TotalNum           Type:   INT    &