更新时间:2023-02-10 16:13:54
要获得在一个整数我的位置
你可以这样做: P
十进制数
To get the decimal digit at position p
of an integer i
you would do this:
(i / pow(p, 10)) % 10;
因此,从最后一位到第一个数字回路,你可以这样做:
So to loop from the last digit to the first digit, you would do this:
int n = 56; // 056
int digit;
while(n) {
digit = n % 10;
n /= 10;
// Do something with digit
}
易于修改做准确的3倍。
Easy to modify to do it exactly 3 times.