Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and medical aesthetics - Java input a digital inversion output.
Java input a digital inversion output.
Find the number of digits of this number first,

Then we divide the remainder by it and we can get it quickly.

It is too inefficient to use String to deal with it.

The reverse () method of StringBuffer is even less desirable. If the last few digits are 0, the output result will be wrong.

///Test.java

Common class test {

Public static void main(String[] args) {

Reverse (12340567);

Reverse (123000);

}

Static void reverse (int a) (

int RS = 0;

while(a & gt; 0){

RS * = 10;

RS+= a % 10;

a/= 10;

}

system . out . println(RS);

}

}