开发者

int to integer list with three pairs

how can i do this integer value is converted to integerlist with three pairs from the and of the integer input 开发者_运维技巧: 24889375 output : [375,889,24]


The same way you do it with one digit, except that you divide and mod by 1000 instead of 10.


You don't list the language, so this will be pseudo code. Use the mod operator (% in The following)

First number = X % 1000; Second Number = (X/1000)%1000; Third Number = (X/1000000)%1000;

Note that these operations are all integer operations. The above only works if the / divide operator is an integer divide. If not, truncate it before calculating the modulo.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜