For example, there is a number: 19911002, the requirement is, I want to get its inverted number: 20011991
The implementation is as follows:
static void reverse(int a) { int rs = 0; while (a > 0) { rs *= 10; rs += a % 10; a /= 10; } System.out.println(rs); }
Pro test is good. . .