Practice outputting an integer in reverse order

The code is as follows:

/*Practice outputting an integer in reverse order, and take out the numbers of bits, tens, hundreds, thousands, etc. * / import Java util. Scanner; Class demo18 {public static void main (string [] args) {scanner SC = new scanner (system. In); system. Out. Println ("please enter:"); int num = sc.nextint(); system. Out. Println ("the number after reverse order is:"); / / if it is a negative number, print the negative number first and change it to a positive number if (Num < 0) {system. Out. Print ("-"); num = - 1 * num;} while(num!=0){ int r=num%10; System.out.print(r); num=num/10; } } }

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>