开发者

int to integer list with three pairs

开发者 https://www.devze.com 2023-01-20 21:54 出处:网络
how can i do this integer value is converted to integerlist with three pairs from the and of the integer

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

精彩评论

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