java implements inversion of numbers

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. . .

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325019596&siteId=291194637
Recommended